Page 1 of 1
Require function
Posted: Tue Nov 12, 2002 4:27 am
by Skywalker
If have a page that is called test.php and in that page ther is an variable called $Test.
Then an other page called uitvoer.php and in when I insert the command require(test.php), can I then use the variable $Test in the page uitvoer.php?
Greathings Skywalker
Posted: Tue Nov 12, 2002 4:44 am
by twigletmac
Why don't you create a couple of test pages to work out the result:
page1.php
Code: Select all
<?php
$test = 'Testing 123';
?>
page2.php
Code: Select all
<?php
include 'page1.php';
if (isset($test)) {
echo $test;
} else {
echo '$test doesn''t exist';
}
?>
Also have a read of the documentation:
http://www.php.net/manual/en/function.require.php
http://www.php.net/manual/en/function.include.php
Mac
Posted: Tue Nov 12, 2002 5:13 am
by Skywalker
I am having a ping script here and I want show the result of the pings on a other page if the are offline else show that ther is nothing offline.
Is this the right way to do it? Or not?
Code: Select all
//page1.php
<?php
$ip='www.test.nl';
$port=80;
$fp = fsockopen ($ip, $port, $errno, $errstr, 30);
if (!$fp) {
echo "<font color="#FF0000">img src="warning.gif"><b>System offline";
$Offline1 = "http server is ofline";
Down</b><p>Error $errno: $errstr";
} else {
echo "<font color="#0000c0"><img src="online.gif"><b>All
systems are stable and running.</b>";
}
?>
//page2.php
<?php
require(page1.php)
if (isset($Offline1)) {
echo $Offline1;
} else {
echo "Alle servers zijn online"; }
if (isset($Offline2)) {
echo $Offline2;
} else {
echo "Alle server zijn online"; }
?>
Posted: Tue Nov 12, 2002 5:32 am
by twigletmac
Could you please edit your post to put your PHP code inbetween [syntax=php]...[/syntax] tags - it makes it a lot easier to read.
Mac