Jump to content

understand something inside include()


hisoka

Recommended Posts

in this code :

<?php

   $file = $_GET['page'];
   if(isset($page))
   {
       include("pages/$page");
   }
   else
   {
       include("index.php");
   }
   ?>

I do not get what does the thing in red mean :

 

include("pages/$page"); two files one is a variable and the other is not ??

 

Link to comment
Share on other sites

pages/ is the name of a folder. $page is a variable that contains a file name that should be inside that folder. Have you read the PHP manual page about strings yet? http://php.net/strings

 

That code is dangerous because it grants the user the ability to view or execute any file they want on your filesystem.

  • Like 1
Link to comment
Share on other sites

the code itself looks incorrectly written. isset is being used against $page, but the variable assigned to $_GET['page'] is $file, and then this undefined $page variable is being used in the include.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...