2010-07-04 101 views
0

我正在使用CodeIgniter for PHP。任何人都可以告訴我爲什麼這段代碼無法正常工作?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代碼不能嵌入?

感謝提前:)

回答

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

除非segment方法有呼應東西的副作用,這不會產生任何輸出。它可能會返回一個字符串,而不是你應該輸出回顯:

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

他是對的,你需要使用回聲。 – ubiquibacon 2010-07-04 09:32:32