Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 236
  • 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
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

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