Results 1 to 4 of 4

Thread: Can Explain is this?

  1. #1
    Join Date
    Mar 2005
    Location
    JB
    Posts
    14
    Rep Power
    0

    Question Can Explain is this?

    PHP Code:
     (@$_POST['disable_styles'] == "") ? $_POST['disable_styles'] = "" 
    I'm beginner in web programming

    anyone can help me? especially bout function ":" on code above.

    appreciate if u could explain every single part above.

    i just need to know meaning only.

  2. #2
    Join Date
    Jun 2001
    Location
    Mystic Kingdoms
    Posts
    2,749
    Rep Power
    271
    'code function' cannot to be declare by 'partial code only'.

  3. #3
    Join Date
    Jan 2006
    Location
    Kuala Lumpur
    Posts
    1
    Rep Power
    0
    (@$_POST['disable_styles'] == "") ? $_POST['disable_styles'] = 0 : "" ;

    IF $_POST['disable_styles'] doesn't contains any value/equals to nothing,
    THEN assign '0' to it($_POST['disable_styles'])

    IF $_POST['disable_styles'] contains something,
    THEN assign ""(NULL or make it empty) to it.
    THEN assign '0' to it($_POST['disable_styles'])

  4. #4
    Join Date
    Aug 2008
    Location
    KL
    Posts
    23
    Rep Power
    0
    Quote Originally Posted by just View Post
    PHP Code:
     (@$_POST['disable_styles'] == "") ? $_POST['disable_styles'] = "" 
    I'm beginner in web programming

    anyone can help me? especially bout function ":" on code above.

    appreciate if u could explain every single part above.
    i just need to know meaning only.

    This is called Ternary operation. It is another syntax to write IF statements.

    The format of Ternary Operation is :

    (condition)?(evaluate if condition was true) : (evaluate if condition was false)

    They are different than normal IF statements,because you can write them inline of the code. You can't do something like:

    my_variable= if(x > 10) { "foo" } else { "bar" };

    but you can do:

    my_variable = (x > 10)?"foo":"bar";

    which will create the same result as:

    if (x > 10) {
    my_variable = 'foo';
    }
    else {
    my_variable = 'bar';
    }

    so if we apply to your case:

    PHP Code:
     (@$_POST['disable_styles'] == "") ? $_POST['disable_styles'] = "" 
    it will have the same result as:

    PHP Code:
    if($_POST['disable_styles']==""){
    $_POST['disable_styles'] = 0;
    }else{
    $_POST['disable_styles'] = ""



    I hope I was helpful

    with regards,


    * Source wikipedia

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Anyone can help me to explain is this?
    By just in forum Website Programming
    Replies: 0
    Last Post: 13-05-2008, 06:25 PM
  2. Bandwidth Issue, Need some explain
    By calvynlee in forum Mamak Stall
    Replies: 17
    Last Post: 10-01-2008, 04:59 PM
  3. How to explain "~pathname\filename.txt"?
    By genzy in forum Webmaster Tools
    Replies: 2
    Last Post: 28-04-2007, 08:50 AM

Posting Permissions

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

Search Engine Optimization by vBSEO 3.5.0 RC1 PL1

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112