Welcome Guest, Not a member yet? Register   Sign In
[Tutorial -Static Pages] about.php expose PHP code!
#1

[eluser]antoniog[/eluser]
Good morning to all.
Today I am starting learning CodeIgniter 2, installation go well at fly, then start tutorial for Static pages.
To home.php its run ok with correct exposition of header and footer, about.php run and expose correctly header and footer but expose PHP code too.
The CI code per home.php I have inserted in pages.php controller like the below code:

Code:
<?php

class Pages extends CI_Controller {

public function view($page = 'home')
{
    if ( ! file_exists('application/views/pages/'.$page.'.php'))
    {
    // Whoops, we don't have a page for that!
    show_404();
    }

    $data['title'] = ucfirst($page); // Capitalize the first letter

    $this->load->view('templates/header', $data);
    $this->load->view('pages/'.$page, $data);
    $this->load->view('templates/footer', $data);

}

}


and rend right output.

For about.php, within it, I have insert this code:

Code:
public function view($page = 'about')
{

      if ( ! file_exists('application/views/pages/'.$page.'.php'))
    {
    // Whoops, we don't have a page for that!
    show_404();
    }

    $data['title'] = ucfirst($page); // Capitalize the first letter

    $this->load->view('templates/header', $data);
    $this->load->view('pages/'.$page, $data);
    $this->load->view('templates/footer', $data);

}


In summary home.php is successful, while also about.php runs properly, and both show header and footer, but the last also shows all the code.
I have try add other code for public function view($page = 'about') ... in pages.php controller but a error message inform me thet is not possible redeclare view().
I have try adding PHP tag and receive the following parse error message
Parse error: syntax error, unexpected T_PUBLIC in ...\myserver.dev\public_html\codeign\application\views\pages\about.php on line 2

Thanks to those who help in the meantime I will try to solve by changing the function of the pages.php controller.
Sorry my English, I am Italian.
#2

[eluser]InsiteFX[/eluser]
it's:
Code:
pages/view/about
#3

[eluser]antoniog[/eluser]
...
#4

[eluser]antoniog[/eluser]
Hi InsiteFX, I solved it.
I put the code in about.php instead must be empty as home.php.
Yes, pages/view/about runs well, but ran fine before too!
The difference is that, then I understood, which is exposed all that is written in the file.




Theme © iAndrew 2016 - Forum software by © MyBB