Page 1 of 1

conditional statement

Posted: Tue Mar 18, 2003 10:32 am
by bsk
i am new to php and have been using cold fusion. i need to find how to do the same thing in php that i have in cold fusion. here is the cold fusion code:
<cfparam name="action" type="numeric" default="1">
<cfif action is 1>
enter text here
</cfif>
<a href="#path_info#?action=3"></a>
<cfif action is 2>
enter text here
</cfif>
<a href="#path_info#?action=3"></a>

all this does is allow you to create different sections within each page so you don't have to create new pages to link to but you can just call up certain parts of the page. i found how to use the if, else, else if statements in php but i can't find a way to create a variable that it's value can change like this. What tag is there to use like the cfparam so i can create a new variable like that? thanks!

Posted: Tue Mar 18, 2003 10:36 am
by m3mn0n

Code: Select all

<?php
if ($action1 = ""){

} elseif($action2 = ""){

} else {

}
?>

...i think. :wink:

Posted: Tue Mar 18, 2003 11:34 am
by daven

Code: Select all

<?php
// If $action is not set, give it a value of 1.
// Similar to what happens with CFPARAM if the variable is not set.  
// You can also do a settype() if you want to cast the variable as an int, real, etc., although it is not necessary
if(!isset($action)){$action=1}

if ($action1 == ""){ // make sure you use '==', not '='.

} elseif($action2 == ""){

} else {

} 
?>