php代码未正确嵌入

时间:2010-07-04 09:03:12

标签: php codeigniter

我正在使用CodeIgniter for PHP。谁能告诉我为什么这段代码不能正常工作?

  <form action="/TestCodeIgniter/index.php/blog/comment_insert/<?php $this->uri->segment(3);?>" method="post">

但是,此代码可以正常工作: -

<?php echo form_open('blog/comment_insert/' . $this->uri->segment(3) ); ?>

我非常确定我的漂亮网址中存在segment(3)。那么,如果我使用普通的HTMl我的PHP代码是不是嵌入式的呢?

提前致谢:)

1 个答案:

答案 0 :(得分:7)

<?php $this->uri->segment(3);?>

除非segment方法具有回显某些内容的副作用,否则不会生成任何输出。它可能会返回一个字符串,您应该使用echo输出:

<?php echo $this->uri->segment(3);?>