Help Combining Code

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
chriscct7
Forum Newbie
Posts: 3
Joined: Tue Jul 03, 2012 3:39 pm

Help Combining Code

Post by chriscct7 »

Hi, I am working on a simple error system that will relay some PHP information only if debug is active (found if imported $global_debug is 1).
As you will note in my code: http://pastebin.com/03HtvpnY
I am using a ton of if else's. What I am trying to do is get it to where if $global_debug is 0 nothing is displayed (blank php file echoed) for security reasons and if it is active then the content will be displayed.
This is what it looks like without the if elses:
http://pastebin.com/V0acPdiT

So the second paste shows you what I want to have if the debug is 0 give or take.

Can someone help me combine this?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Help Combining Code

Post by Celauran »

Just wrap the form in an if statement. There's no need for the empty else {} block.

Code: Select all

<?php if ($global_debug == 1): ?>
form goes here
<?php endif; ?>
chriscct7
Forum Newbie
Posts: 3
Joined: Tue Jul 03, 2012 3:39 pm

Re: Help Combining Code

Post by chriscct7 »

Worked Perfectly. Thanks for your help. This PHP tag looks interesting, and very useful. Do you know any Codex or reference material I could study it with?

-Chris
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Help Combining Code

Post by Celauran »

Not quite sure what you mean. If you're referring to the if: endif; block, that's just an alternate syntax to braces.
chriscct7
Forum Newbie
Posts: 3
Joined: Tue Jul 03, 2012 3:39 pm

Re: Help Combining Code

Post by chriscct7 »

Never seen that before.

-Chris
Post Reply