Page 1 of 1

checking to see if global variable exists

Posted: Mon Sep 18, 2006 3:23 am
by nutstretch
Weirdan | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I am trying to see if a global variable exists and if it doesn't I want to create one.  

the code i have used on my test page is:

Code: Select all

hello world
<?php

if (empty($_REQUEST['VendorTxCode'] == true) 
{
$ThisVendorTxcode = $today.(rand(0,32000)*rand(0,32000));
print "new ".$ThisVendorTxCode;
}
else
{
$ThisVendorTxcode = $_REQUEST['VendorTxCode'];
print $ThisVendorTxCode;
}
?>
This page is showing up blank. Please can someone see a or several fatal flaws for me. NOt even the hello world is showing

Thanks in anticipation

Nuts


Weirdan | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Mon Sep 18, 2006 3:30 am
by Weirdan
you missed a paren in your if clause

Posted: Mon Sep 18, 2006 3:46 am
by aerodromoi
As empty returns only true/false you could also save a few bytes by using

Code: Select all

if(empty($var))