Can someone help me understand this syntax

Posted on 2009-04-17
Last Modified: 2012-05-06

Just a quick one, can anyone help me understand these few lines..

if ((!isset($_GET["cPath"]) or $_GET["cPath"]=="") && (!isset($_GET["keywords"])))
header("Location: home page ");

(I've put in home page)


Question by:chriscounter07
    LVL 39

    Expert Comment

    by:Pratima Pharande
    if ((!isset($_GET["cPath"]) or $_GET["cPath"]=="") && (!isset($_GET["keywords"])))

    isset($_GET["cPath"])   == whethere the Field present in Get method

    then OR means

    $_GET["cPath"]==""   if present then is it null ?

    If both are True the

    AND  that is &&
    isset($_GET["keywords"]) whethere the Field present in Get method

    LVL 16

    Accepted Solution

    Logically it means:

    If the variable cPath is empty and the variable keywords is also empty then redirect the user to the home page
    LVL 16

    Expert Comment

    Here is a lesson:

    1.  An exclamation point ! means NOT.
    2. $_GET is a method used by a form.  The alternative is $_POST.  These are used in a form such as <form name="form1" action="" method="get">
    3. == means equals.
    4. double quotes "" means empty string
    5. && means AND
    6. isset means is set as in ... the variable keywords is set to monkey blood

    So, if you place an exclamation point in front of isset then !isset would mean: not set or also known as an empty string.  The first part of your code means the same thing which is not necessary to have both:  

    ((!isset($_GET["cPath"]) means the same things as
     $_GET["cPath"]=="") because !isset (variable not set) means the same thing as "" (variable equals and empty string)


    Author Comment

    and a fine lesson that is.  Extremely helpful.


    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    The first time you look at a web page and its source code, you are probably a little intimidated by the use of symbols and jargon that really looks foreign to you. You might not even know where to start to begin learning what it all means. That’…
    Uploading files to the web server has become common part of almost any kind of web application. People use different technologies to solve this, but regardless of the technology used, it is always useful to have some kind of progress indicator shown…
    Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
    The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

    755 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

    22 Experts available now in Live!

    Get 1:1 Help Now