/    Sign up×
Community /Pin to ProfileBookmark

If statement outputing non-php code

Here is a simple if statement:

[code=php]
if($foo == bar){

echo $foo;
?>

Cat

}

[/code]

I would like to have the if display what is between the brackets whether it is in <?php ?> or not. Is this achievable?

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@jasonahouleNov 12.2007 — It isn't really clear what you mean. Are you talking about markup? Are you trying to do something like this?
<i>
</i>&lt;?
if($foo == 'bar') {
?&gt;
&lt;div&gt;Write out some html to the &lt;?= $_SERVER['PHP_SELF'] ?&gt; page&lt;/div&gt;
&lt;?
}
?&gt;
Copy linkTweet thisAlerts:
@hdoggauthorNov 12.2007 — Thanks.

Is there any difference between using [code=php]<?php ?>[/code] and [code=php]<? ?>[/code]?
Copy linkTweet thisAlerts:
@scragarNov 12.2007 — not all servers accept the short tags([b]<?[/b]), because of conflicts with xml.

no other difference(all servers will accept [b]<?php[/b])
×

Success!

Help @hdogg spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...