views:

29

answers:

1

Hello,

I am using CodeIgniter for PHP. Can anybody tell me why is this code not working properly?

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

However, this code works fine :-

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

I am very much sure that segment(3) exists in my pretty url. Then how come if i use plain HTMl my php code doesn't get embedded?

Thanks in advance :)

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

Unless the segment method has the side effect of echoing something, this won't generate any output. It probably returns a string instead, which you should ouput with echo:

<?php echo $this->uri->segment(3);?>
Artefacto
he is right, you need to use echo.
typoknig