Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 235
  • Last Modified:

if else ? : notation

<?php echo (isset($pageTitle)) ? $pageTitle : 'Some Content Site';

Open in new window


I still can not conceptualize this example

if page isset use pagetitle else some content site
0
rgb192
Asked:
rgb192
2 Solutions
 
Marco GasiFreelancerCommented:
Yes, is the ternary operator(http://www.php.net/ternary)

It is as you wrote:
if (isset($pageTitle))
{
  echo $pageTitle;
}
else
{
  echo 'Some Content Site';
}

Open in new window

0
 
GaryCommented:
::No points for this::

I still can not conceptualize this example

if page isset use pagetitle else some content site


You answered your own question ;o)
0
 
Cornelia YoderArtistCommented:
That notation is some sadist's idea of shortening his code.   Don't use it, all it does is complicate something that should be straightforward, and make code unreadable.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
GaryCommented:
Really, I use it all the time.
0
 
rgb192Author Commented:
Gary wrote: no points.

Now, I understand if else better and may/mayNot use this
0
 
GaryCommented:
There should only be one answer and that is Marco's nothing else answered your question.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now