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!
conditional statement
Moderator: General Moderators
- daven
- Forum Contributor
- Posts: 332
- Joined: Tue Dec 17, 2002 1:29 pm
- Location: Gaithersburg, MD
- Contact:
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 {
}
?>