conditional statement

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bsk
Forum Newbie
Posts: 1
Joined: Tue Mar 18, 2003 10:32 am

conditional statement

Post 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!
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Code: Select all

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

} elseif($action2 = ""){

} else {

}
?>

...i think. :wink:
User avatar
daven
Forum Contributor
Posts: 332
Joined: Tue Dec 17, 2002 1:29 pm
Location: Gaithersburg, MD
Contact:

Post 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 {

} 
?>
Post Reply