Forum Moderators: coopster
why can't i echo variables set with expressions in an include. and just recently it seems like its randomly choosing which variables work and which don't even if they aren't set with expressions.
<?php
$mm = 3440;
$inch = $mm / 25.4;
$inchint = settype($inch,"int");
include('output.php');
echo $mm; // outputs 3440
echo $inch; // outputs 135.43..etc
echo $inchint; // outputs 135.43..etc
?>
output.php
<?php
echo $mm; // outputs 3440
echo $inch; // outputs NULL
echo $inchint; // outputs 0
?>
$inchint should return a boolean only on success or failure.
What do you get with this script
<?php
ini_set("display_errors", "on");
ini_set('error_reporting', E_ALL);
$mm = 3440;
$inch = $mm / 25.4;
$inchint = settype($inch,"int");include('output.php');
echo "<pre>";var_dump($GLOBALS);
?>
$inchint = [url=http://www.php.net/set-type]settype[/url]($inch,"integer");
As for the other variable, it should be working as you have intended it to. Try what was suggested above and see what you get as a result.
Also, welcome to WebmasterWorld! :)