Put PHP img src inside string

I'm looking at a PHP logic problem for me, but I can't fix it, so I ask you guys here. How can I call/combine the underneath PHP img with the var string method?

I would like to call an image with PHP:

<img src="<?php echo $this->getSkinUrl('images/prev.gif'); ?>

But I would like to call the php from the following string:

var str_buffer = new String (
 "<table width="100%">n"+
    "<tr>n <td>n"+
    "<img src="prev.gif" width="16" height="16" border="0""+
    " alt="previous month"></td>n"+
    "</tr>n</table>n"
);

If I understand correctly you want to implement the method used in the PHP for calling a function, within the Javascript code?

If so, You need to enclose the Javascript segments within a PHP output statement. Eg.

    echo 'var str_buffer = new String (
 "<table width="100%">n"+
    "<tr>n <td>n"+
    "<img src="' . $call->getSkinUrl('images/prev.gif'); . '" width="16" height="16" border="0""+
    " alt="previous month"></td>n"+
    "</tr>n</table>n"
);';

Aditionally, you will need to implement the class/object on the page where you want to use it.

链接地址: http://www.djcxy.com/p/96572.html

上一篇: 如何让工厂类在PHP中创建对象实例?

下一篇: 将PHP img src放入字符串中