简体   繁体   中英

parsing javascript codes with php echo

I want to parsing this code with php echo :

<li><a onclick="resource('showvideo',<?= $myvideo->id?>);"> <i class="fa fa-file-video-o"></i>&nbsp; {{$myvideo->title}}</a></li>

but results get to this code :

<li><a onclick="resource(' showvideo',44);"> <i class="fa fa-file-video-o"></i>&nbsp; test</a></li>

I have a new blank space before showvideo in resource parameters! my php echo :

echo "html +="."'<li><a onclick=\"resource(\"showvideo\",44);\"><i class=\"fa fa-file-video-o\"></i>&nbsp;sdfdsf</a></li>'";

I try so much to clear this blank space but I failed. please help me

Try this

echo "html +="."'<li><a onclick='resource(&#34;showvideo&#34;,44);\'><i class=\"fa fa-file-video-o\"></i>&nbsp;sdfdsf</a></li>'";

And you were getting spaces due to improper use of quotes in your string.

Hope it helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM