CodeIgniter Forums
View not executing PHP code - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: View not executing PHP code (/thread-20919.html)



View not executing PHP code - El Forum - 07-25-2009

[eluser]HooJee[/eluser]
Hi Guys

I cannot execute PHP code in my view files. The controllers on the other hand work perfectly fine. I am using WAMP 2.0


View not executing PHP code - El Forum - 07-25-2009

[eluser]kgill[/eluser]
It would be helpful to see the code in the view and the controller, also are you getting any error messages? If you want help you have to give us a little more info. Smile


View not executing PHP code - El Forum - 07-25-2009

[eluser]HooJee[/eluser]
The code is pretty straightforward. See below:

// home.php controller
Code:
<?php
class Home extends Controller {

    function index()
    {
        $this->load->view('homeview');
    }
}
?>

//homeview.php
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
   "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
&lt;html &gt;
&lt;head&gt;
    &lt;title&gt;&lt;? echo "testing"?&gt;&lt;/title&gt;
&lt;/head&gt;
&lt;/body&gt;
  &lt;!-- some stuff --&gt;
&lt;/body&gt;
&lt;/html&gt;



View not executing PHP code - El Forum - 07-25-2009

[eluser]wabu[/eluser]
Is short_open_tag enabled in php.ini (http://us3.php.net/manual/en/ini.core.php)? You might try using "&lt;?php" in your template first to see if that works.


View not executing PHP code - El Forum - 07-25-2009

[eluser]HooJee[/eluser]
Oh yes! Silly me, how could I forget. BTW, I have noticed people do the following to get the base url:
&lt;?=base_url?&gt;

Whenever I try it I get a blank. It'll only work if I use echo. Do you know why this could be happening?


View not executing PHP code - El Forum - 07-25-2009

[eluser]jayrulez[/eluser]
[quote author="HooJee" date="1248563896"]Oh yes! Silly me, how could I forget. BTW, I have noticed people do the following to get the base url:
&lt;?=base_url?&gt;

Whenever I try it I get a blank. It'll only work if I use echo. Do you know why this could be happening?[/quote]

for d same reason above