Solved

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

Posted on 2016-11-28
3
17 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 6

Accepted Solution

by:
Mukesh Yadav earned 250 total points
Comment Utility
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 21

Assisted Solution

by:Kim Walker
Kim Walker earned 250 total points
Comment Utility
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
Comment Utility
Thanks
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

772 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now