Solved

What is the meaning of this one line code in php?

Posted on 2016-11-28
3
62 Views
Last Modified: 2016-11-29
Hello;

I am trying to reconstruct a website,now i see this code below regarding the isset() function in php ,please let me know its meaning,i have read the php.net manual for isset() function.

$code = (isset($_GET["artistfamilye"]) ? $_GET['artistfamilye'] : null );

Open in new window


Thanks
0
Comment
Question by:MOSTAGHASSI
[X]
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
3 Comments
 
LVL 9

Accepted Solution

by:
Mukesh Yadav earned 250 total points
ID: 41905241
In this code we are checking for query string "artistfamilye" if it exists then assigning value to a variable else assigning null to that variable and we are using ternary operator to assign different value based on isset function result.

isset function returns true is variable is defined and false if variable is not defined;
0
 
LVL 22

Assisted Solution

by:Kim Walker
Kim Walker earned 250 total points
ID: 41905275
This statement is called a ternary conditional statement. It is equivalent to:
if (isset($_GET["artistfamilye"]) ) {
    $code = $_GET['artistfamilye'];
} else {
    $code = null;
}

Open in new window

1
 

Author Closing Comment

by:MOSTAGHASSI
ID: 41905298
Thanks
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

707 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