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
Require function
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Why don't you create a couple of test pages to work out the result:
page1.php
page2.php
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
page1.php
Code: Select all
<?php
$test = 'Testing 123';
?>Code: Select all
<?php
include 'page1.php';
if (isset($test)) {
echo $test;
} else {
echo '$test doesn''t exist';
}
?>http://www.php.net/manual/en/function.require.php
http://www.php.net/manual/en/function.include.php
Mac
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?
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"; }
?>
Last edited by Skywalker on Tue Nov 12, 2002 5:52 am, edited 4 times in total.
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK