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
LVL 1
rgb192Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Marco GasiConnect With a Mentor FreelancerCommented:
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 YoderConnect With a Mentor ArtistCommented:
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
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
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
All Courses

From novice to tech pro — start learning today.