Forum Moderators: coopster

Message Too Old, No Replies

how to echo variables without having to define

See my script for more details

         

Twisted Mind

11:09 am on Oct 13, 2005 (gmt 0)

10+ Year Member



I want to make it possible to echo variables
Without having defined them already
Like $var = "$var2" but that var2 has no value but will get it were it gets echo'd

description of problem was enough, no code necessary -- coopster

[edited by: coopster at 2:33 pm (utc) on Oct. 13, 2005]
[edit reason] removed unnecessary code [/edit]

Twisted Mind

11:40 am on Oct 13, 2005 (gmt 0)

10+ Year Member



Might this be not possible or dont you know?

Twisted Mind

12:50 pm on Oct 13, 2005 (gmt 0)

10+ Year Member



no one :(

tomda

1:03 pm on Oct 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Not sure I understood you clearly but I would say NO.

A variable is a variable and must have a value.
If not value is given, then the variable is NULL (that is $var="")

coopster

2:39 pm on Oct 13, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



PHP has some nice built-in functions to test whether a variable exists yet. I would probably assign the value after checking to see if the variable isset() [php.net] yet. I often use the ternary operation to do so ...
$var = (isset($var1))? $var1 : 'default_value';

This type of approach comes in very handy -- especially when checking to see if a user has filled in an HTML <form> value.