some code explaining

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
bugpanye
Forum Newbie
Posts: 7
Joined: Fri Nov 07, 2008 3:11 am

some code explaining

Post by bugpanye »

i've been doing php for a few months now.. so far its been easy to use,
however i stumbled across a page which has a code like this

Code: Select all

$path = !empty($_REQUEST['path']) ? $_REQUEST['path'] : dirname(__FILE__);
so i have this piece of code right, i'm guessing the ? is suppose to mean if satisfy the previous condition
however i'm pretty loss at that ":"

can anyone explain to me what does the ":" mean?

and lastly.. can you also point me to a page where i can learn all these "special characters" cause i dont know the keyword to search for thanks!
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: some code explaining

Post by Christopher »

This:

Code: Select all

$path = !empty($_REQUEST['path']) ? $_REQUEST['path'] : dirname(__FILE__);
Is the same as this:

Code: Select all

if (!empty($_REQUEST['path'])) {
    $path = $_REQUEST['path'];
} else {
    $path = dirname(__FILE__);
}
(#10850)
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: some code explaining

Post by requinix »

bugpanye wrote:and lastly.. can you also point me to a page where i can learn all these "special characters" cause i dont know the keyword to search for thanks!
There isn't really a list of symbols (that I know of) but the operator precedence page comes really close.
Post Reply