SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast morrty's Avatar
    Join Date
    Oct 2008
    Location
    Ontario, Canada
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with variables and Super Global $_GET['']

    How come I can't get this to work, is it proper syntax?

    PHP Code:
    $site checkSite(strip_tags($_GET['site'])); 
    This on the other hand does work:

    PHP Code:
    $getSite $_GET['site'];
    $site checkSite(strip_tags($getSite)); 

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    No difference, zero, nada, nowt.

    Do you have more context? Maybe produce some code to reproduce?
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    SitePoint Enthusiast morrty's Avatar
    Join Date
    Oct 2008
    Location
    Ontario, Canada
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, think I figured out the issue.

    It was in my if statement using isset().

    Took that out and works with both now.

    Edit: What is the difference between this:

    PHP Code:
    if ($var1 && $var2 && $var3) {


    Compared to this:

    PHP Code:
    if (isset($var1) && isset($var2) && isset($var3)) {



  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by morrty View Post
    Ok, think I figured out the issue.

    It was in my if statement using isset().

    Took that out and works with both now.

    Edit: What is the difference between this:

    PHP Code:
    if ($var1 && $var2 && $var3) {


    Compared to this:

    PHP Code:
    if (isset($var1) && isset($var2) && isset($var3)) {


    The first is testing that none of them are false, the second is testing that all of them exist.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  5. #5
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    To add to Felgall's post, maybe a quick example..
    PHP Code:
    <?php
    $var1 
    'false';

    $var2 0;

    $var3 false;

    if(
    $var1 && $var2 && $var3)
    {
        
    #nope
    }

    if(isset(
    $var1) && isset($var2) && isset($var3))
    {
        
    #yup
    }
    ?>
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  6. #6
    SitePoint Enthusiast morrty's Avatar
    Join Date
    Oct 2008
    Location
    Ontario, Canada
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ahh ok, I learn something new everyday.

    Thanks for the help.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •