I have 2 simple PHP files:
test.php
<?php
$a=10;
require "use.php?c=$a";
?>
use.php:
<?php
$test=$_GET['c'];
echo $test;
?>
But it returns nothing.
What is wrong?
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.
include()andrequire()do not make HTTP requests unless you supply a full URL, they work on the local file system.$_GETand friends use URL parameters when they are populated. You code should not work, because you are trying torequire()a file calleduse.php?c=$a, not a file calleduse.phppassing the value$ato the parameterc, which is what you want.This will work:
test.php
use.php
If you are getting no output, you should enable error reporting: