Warrior Forum - The #1 Digital Marketing Forum & Marketplace

Warrior Forum - The #1 Digital Marketing Forum & Marketplace (https://www.warriorforum.com/)
-   Programming (https://www.warriorforum.com/programming/)
-   -   php include (https://www.warriorforum.com/programming/441820-php-include.html)

brandon2664 29th August 2011 07:12 PM

php include
 
Hey guys i have a general member.php where users go after login. I want to make it more personal.

If they are interested in surfing i want to include the contents from surfing.php, if they are interested in skiing i want to include skiing.php.

I can PRINT their interest like this
<?php print $_SESSION['interest']; ?>

skiing.php and surfing.php are in my main directory www.mywebsite.com/surfing.php
Please help

rainso0 30th August 2011 02:54 AM

Re: php include
 
The include() statement includes and evaluates the specified file.
The documentation below also applies to require().
Files are included based on the file path given or, if none is given, the include_path specified. If the file isn't found in the include_path, include() will finally check in the calling script's own directory and the current working directory before failing. The include() construct will emit a warning if it cannot find a file; this is different behavior from require(), which will emit a fatal error.
If a path is defined — whether absolute (starting with a drive letter or \ on Windows, or / on Unix/Linux systems) or relative to the current directory (starting with . or ..) — the include_path will be ignored altogether. For example, if a filename begins with ../, the parser will look in the parent directory to find the requested file.
For more information on how PHP handles including files and the include path, see the documentation for include_path.
When a file is included, the code it contains inherits the variable scope of the line on which the include occurs. Any variables available at that line in the calling file will be available within the called file, from that point forward. However, all functions and classes defined in the included file have the global scope.

KirkMcD 30th August 2011 05:39 AM

Re: php include
 
include $_SESSION['interest'].".php";
is the simplest way, but you need be careful that $_SESSION['interest'] is only an existing page.

brandon2664 30th August 2011 08:46 AM

Re: php include
 
Thanks alot I really appreciate it.


All times are GMT -6. The time now is 11:42 AM.