Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

863 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

21 Experts available now in Live!

Get 1:1 Help Now