为什么我的PHP变量不会出现在CakePHP视图中的HREF中?

时间:2022-11-26 10:10:25

In my CakePHP code I have the following code. If i click on the image delete it moves to the link in href. In the href I dont know how to display my php value. I tried it like below But it didn't work.

在我的CakePHP代码中,我有以下代码。如果我点击图像删除它会移动到href中的链接。在href我不知道如何显示我的PHP值。我尝试过如下,但它不起作用。

   <a href="http://localhost/cake_1.2.1.8004/index.php/forms/delete/"<?php echo $r['Form']['id'];?> >
    <img border="0" alt="Delete" src="/cake_1.2.1.8004/app/webroot/img/delete.png"/>
  </a>

Any suggestions?

2 个解决方案

#1


Put your echo in your quotes:

把你的回音放在你的报价中:

<a href="http://localhost/cake_1.2.1.8004/index.php/forms/delete/<?php echo $r['Form']['id'];?>">
    <img border="0" alt="Delete" src="/cake_1.2.1.8004/app/webroot/img/delete.png"/>
</a>

#2


use cakephp view helpers:

使用cakephp查看助手:

<?php
    echo $html->link(
        $html->image('delete.png'),
        array('action'=>'delete', $r['Form']['id']),
        array(),
        'really delete?',
        false
    );
?>

#1


Put your echo in your quotes:

把你的回音放在你的报价中:

<a href="http://localhost/cake_1.2.1.8004/index.php/forms/delete/<?php echo $r['Form']['id'];?>">
    <img border="0" alt="Delete" src="/cake_1.2.1.8004/app/webroot/img/delete.png"/>
</a>

#2


use cakephp view helpers:

使用cakephp查看助手:

<?php
    echo $html->link(
        $html->image('delete.png'),
        array('action'=>'delete', $r['Form']['id']),
        array(),
        'really delete?',
        false
    );
?>