Forum Moderators: coopster
Your If/Else Condition not look like php if/else. Look at the below one.
if(Some Condition){
// If the Condition true execute this block of code
}
else{
//if condition is false execute this block of code
}
Other wise you can do the below one
if(condition){
// Some Code
}
else if(condition){
// Some Code
}
else if(condition){
// Some Code
}
else{
// Some COde
}
for More Information please look at PHP Manual.
Thanks
Mahabub
Since I'm making a templating system, I want it to parse the if tags in HTML <if> tags
Sort of like this -
replace <if="(.+?)"> with if( $1 ) {
replace <else /> with } else {
replace </if> with }
Instead of doing that literally, I wanted to make it more like this.
if the argument provided is true, replace the whole if statement with the content provided for if it's true.
if it isn't true, just remove the whole thing altogether - unless there is an else statement. If there is, replace it with the content for else.
Unless you are on about this type of PHP parsing:
[b]<?php[/b]
IF ($expression)
[b]{[/b]
[b]?>[/b]
<strong>This is true.</strong>
[b]<?php[/b]
[b]}[/b]
ELSE
[b]{[/b]
[b]?>[/b]
<strong>This is false.</strong>
[b]<?php[/b]
[b]}[/b]
[b]?>[/b]
<?php if ($expression): ?>
<strong>This is true.</strong>
<?php else: ?>
<strong>This is false.</strong>
<?php endif; ?>
This is really the same as g1smd's code, just an alternative syntax.