Reply to Is it possible to pass a variable to a PHP script from inside another PHP piece of code?

Your name:

Reply:


Posted by leonardodiserpierodavinci@gmail.com on 10/27/07 21:44

Hi. Sorry for what is perhaps a neophyte question: is it possible to
pass a variable to a PHP script from inside another PHP piece of code?

For instance, the file test.php (which of course resides on a
webserver that supports PHP) is as such:

[some HTML code...]
<?php
echo("<i>the variable abc contains " . $_GET['abc'] . "</i>");
?>
[some more HTML code...]

and if I open this file directly i.e. by typing test.php?abc=888 in
the URL line of a web browser, I correctly get the message "the
variable abc contains 888" in italic, surrounded by the HTML content.

Now, let's say that I want to include all this content in another
file, index.php.
I tried to call it as such in index.php

[other HTML...]
<?php
include "test.php?abc=888";
?>
[yet other HTML...]

which is not the correct way as it gives the following error:

Warning: main(l/test.php?abc=888) [function.main]: failed to open
stream: No such file or directory in /home/www/index.php on line 52
Warning: main() [function.include]: Failed opening 'l/test.php?
abc=888' for inclusion (include_path='.:/usr/share/php:/usr/share/
pear') in /home/www/index.php on line 52

How should I call the file?
Thanks in advance for any hint!

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация