alex1985 0 Report post Posted March 19, 2008 As you get noticed before, I am studying PHP in examples like using the tutorials as well as books itself. Through my readings, I get this function <?php endif; ?> a lot of times. So, what do you mean by this function, and what does it do exactly? Share this post Link to post Share on other sites
sonesay 7 Report post Posted March 19, 2008 Google = http://www.phpbuilder.com/It looks like it just closes the if statement blocks you make. I never use it so I don't think you should worry about closing it either. I doubt many people use it as its more unnecessary typing. Share this post Link to post Share on other sites
darran 0 Report post Posted March 19, 2008 More often than not I would use the {} instead of the endif statement. It is just redundant in my opinion. So it would look something like this: <?php if ($number == 1) { ----some code here----}<?php> Share this post Link to post Share on other sites
truefusion 3 Report post Posted March 19, 2008 Looks like something you'd see in Python. But i've been spoiled by the curly brackets. It's so much quicker to type curly brackets, which is why i haven't taken the time to learn Python. Share this post Link to post Share on other sites
alex1985 0 Report post Posted March 19, 2008 It's still complicated for me?! Share this post Link to post Share on other sites
rvalkass 5 Report post Posted March 19, 2008 There are three ways to write an if statement depending on what you want to do and what your coding style is like. I shall give examples below: "Standard" If Statement This is your bog standard if statement, used millions of times by pretty much everyone: if ( condition ) { code to execute if condition === TRUE} If the condition is true then the code between the curly braces - { } - gets run. If the condition is false then the code between the curly braces is ignored. "Verbose" If Statement This is the slightly longer/older style if statement. It is more similar to if statements in older programming languages. if ( condition ) : Code here is executed if condition === TRUEendif; Here the code that gets run if the condition is true starts with a colon : and ends with endif;This is sometimes useful to use if there are lots of curly braces dotted around your script, as it makes clear exactly what you are closing (if, while, else, foreach, etc.). "Short" If Statement This is used to execute one command, and only one command, when the condition is true. It has no real start or end, and is simply made up with the if statement. Whatever the next line is is only executed when the condition is true. if ( condition ) This line gets executed if condition === TRUE;This line is always run;So is this one; The line that is part of the if statement usually gets indented to make it clearer that it is only run when the if statement is true. You might want to take a look at the following two manual pages for more information about exactly how they work if it still isn't totally clear: http://forums.xisto.com/no_longer_exists/ http://forums.xisto.com/no_longer_exists/ Share this post Link to post Share on other sites
alex1985 0 Report post Posted March 19, 2008 There are three ways to write an if statement depending on what you want to do and what your coding style is like. I shall give examples below: "Standard" If Statement This is your bog standard if statement, used millions of times by pretty much everyone: if ( condition ) { code to execute if condition === TRUE} If the condition is true then the code between the curly braces - { } - gets run. If the condition is false then the code between the curly braces is ignored. "Verbose" If Statement This is the slightly longer/older style if statement. It is more similar to if statements in older programming languages. if ( condition ) : Code here is executed if condition === TRUEendif; Here the code that gets run if the condition is true starts with a colon : and ends with endif;This is sometimes useful to use if there are lots of curly braces dotted around your script, as it makes clear exactly what you are closing (if, while, else, foreach, etc.). "Short" If Statement This is used to execute one command, and only one command, when the condition is true. It has no real start or end, and is simply made up with the if statement. Whatever the next line is is only executed when the condition is true. if ( condition ) This line gets executed if condition === TRUE;This line is always run;So is this one; The line that is part of the if statement usually gets indented to make it clearer that it is only run when the if statement is true. You might want to take a look at the following two manual pages for more information about exactly how they work if it still isn't totally clear: http://forums.xisto.com/no_longer_exists/ http://forums.xisto.com/no_longer_exists/ Oh, thanks. It's clear now!!! Share this post Link to post Share on other sites