Solved

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

Posted on 2016-11-28
3
52 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
3 Comments
 
LVL 8

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

829 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