I am wondering if there is a way to pass a variable to a file you are including via include()?
I tried this but got an error:
include("header_alt.php?img=hey");
Is there a way to do that?
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Just define your variable in the first file ; for instance, in
temp.php:And use it in the second file ;
temp-2.php:And it should work : I’m getting this output, from
temp-2.php:The query-string syntax, using stuff like
?img=heyis used when you are requesting some data from a distant server (like when you are using your browser to surf on websites), not when including a file that is on the same server.