I am wondering if this is possible at all to pass a varibale into an included file in this manner, I know I can just set the variable but im wonder ig this would work this way as well or not?


//file_1.php

<?PHP

require_once "file_2.php?size=2";

?>

//file_2.php

<?PHP

$size = (!empty($_GET['size'])) ? $_GET['size'] : 1;

echo $size;   //shows "2"

?>
    jasondavis wrote:

    im wonder ig this would work this way as well or not?

    Why not try it and find out?

    If you had tried it, you would find that it actually does not work - query strings are only parsed/handled in the context of a webserver, whereas you're trying to tell the server's filesystem that you want the file named "file_2.php?size=2".

      ok your right I figured it wouldnt but I thought maybe there was a trick to it possibly, thanks though

        Write a Reply...