if else ? : notation

Posted on 2014-03-23
Last Modified: 2014-03-23
<?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
Question by:rgb192
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 31

Accepted Solution

Marco Gasi earned 350 total points
ID: 39948756
Yes, is the ternary operator(

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

Open in new window

LVL 58

Expert Comment

ID: 39948782
::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)
LVL 27

Assisted Solution

by:Cornelia Yoder
Cornelia Yoder earned 150 total points
ID: 39948826
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.
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!

LVL 58

Expert Comment

ID: 39948843
Really, I use it all the time.

Author Closing Comment

ID: 39948936
Gary wrote: no points.

Now, I understand if else better and may/mayNot use this
LVL 58

Expert Comment

ID: 39948941
There should only be one answer and that is Marco's nothing else answered your question.

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode ( is the major subset of a GPS coordinate (, the other parts being the altitude and t…
This article discusses how to create an extensible mechanism for linked drop downs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question