Jump to content

Recommended Posts

Problem... and hopefully an easy one to solve with someone's help.

 

My page in question is "video.php" from whose address bar i use $vidID=$_GET['vidID']; to obtain the vidID variable. Now, within my page i use quite a few of echo file_get_contents to break down my website and make it easier to design and manage.

 

From "video.php" i use echo file_get_contents to load "screen.php"

 

My problem is that I need to be able to use the $vidID variable WITHIN screen.php, but the information doesn't seem to work...

 

how can i invisibly transport the value of $vidID into screen.php?

 

Many thanks in advance my favourite people!

Link to comment
https://forums.phpfreaks.com/topic/120947-solved-echo-file_get_contents-query/
Share on other sites

*facepalm*

 

When you use file_get_contents() and pass it a filesystem filename rather than a URL, it just reads the file.  If you pass it a full URL so PHP uses its file wrapper, you get the output of the script.  include actually executes a file on the filesystem and incorporates it into the current script.

it is actually beginning to sink in, and i am grateful for having patience to explain it to me. Having one last error though...

 

the url of the page in question is "...co.uk/advice/video.php" and the one i'm trying to include is "...co.uk/contents/screen.php"

 

they're no hierarchy, they're in completely different folders. shouldn't the follwing be working so?

 

video.php contains...

 

echo include("/contents/screen.php");

 

cos now i'm getting

 

Warning: include(/contents/screen.php) [function.include]: failed to open stream: No such file or directory in /home/e1seix/public_html/advice/video.php on line 16

 

Warning: include() [function.include]: Failed opening '/contents/screen.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/e1seix/public_html/advice/video.php on line 16

 

in my defence, it's late for me. lol

You cannot echo an include, by the way.  Just include(), with no echo.

 

include('../contents/screen.php');

 

P.S: For anyone who wants to correct me, I know that you CAN echo an include() if it returns something, but that's not the case here and it's not all too common anyway.

If you echo an include, if the include was successful it will just echo 1, meaning true. No point really.

 

<?php
//file phpfreaks.php
echo 'phpfreaks';
?>
<?php
//some other file
echo include('phpfreaks.php'); //will return: phpfreaks1
?>

 

Your point is right though, what's the meaning of echoing an included file :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.