For my website, I want to store the general format of the site in a single PHP file in one place, and in each The content of different pages in the local location of the page I then want to give the address of the title and content in the included file through a variable.
However, I can not get the included format file to read the archived data and title and content data.
Alias, the file asked for a different page will be:
The format file will be:
& lt; Html & gt; ... & lt; Title & gt; & Lt ;? Php echo $ title; ? & Gt; & Lt; / Title & gt; ... & lt ?? Includes Php ($ source_file); ? & Gt; ...
I remember reading something somewhere to get the variables in the beginning of the format file to include the variable, although I do not remember what it is or where I found the information .
If you want to use, then include ()
is not a file To output the actual content of ... readfile ()
will not parse the PHP code at all, so there is no way to pass the variable to do this.
The reason you are seeing is the PHP code being executed that your web server is actually making another HTTP request (own?), And running another process to execute your PHP. This second process will not have the same session, nor will it have access to any cookie, or other variables from its first process.
You can pass some variables using the GET parameter, but if you want to include the file on the same server, you should just use included ()
If you want to include the file that is on the other server, you should stop it and think about what you are doing because you are asking for trouble
Comments
Post a Comment