php - Passing a tag in array using phalcon framework -


i using phalcon framework , want pass tag javascript function href. code:

$arr[] = array($first, $second,"<a href='javascript:openoutwardfrm('inventory/outward/?categoryid=2&amp;itemid=1')'><i class='fa fa-edit'></i></a>");  

the problem in href section. it's taking "javascript:openoutwardfrm(". want href string javascript:openoutwardfrm('inventory/outward/?categoryid=2&itemid=1')

pay attention quotes: far browser concerned, link's href 'javascript:openoutwardfrm(' (as that's bit between quotes), , rest of stuff follows garbage.

if use double quotes href , class things become clearer work with.

let's start string: <a href="javascript:openoutwardfrm('inventory/outward/?categoryid=2&amp;itemid=1')"><i class="fa fa-edit"></i></a> (notice how, now, quotes nice , balanced - href in double quotes, , function argument in single quotes).

now, want use in php, add our array. we'll use double quotes enclose it, means need escape every double quote that's present, putting backslash in front of it: $html = "<a href=\"javascript:openoutwardfrm('inventory/outward/?categoryid=2&amp;itemid=1')\"><i class=\"fa fa-edit\"></i></a>" (notice how quotes still balanced).

putting in original example: $arr[] = array($first, $second, "<a href=\"javascript:openoutwardfrm('inventory/outward/?categoryid=2&amp;itemid=1')\"><i class=\"fa fa-edit\"></i></a>");.

make sense?


Comments