Doubt in PHP

Discussion in 'PHP' started by hemasid, Mar 17, 2011.

  1. #1
    I tried this:

    $whatsit="2";
    echo "value is".var_dump($whatsit)."<br/>";

    how can i get an output of this:
    string(1) "2" value is


    Can any one pls explain??
    Thanks in advance
     
    hemasid, Mar 17, 2011 IP
  2. dgreenhouse

    dgreenhouse Peon

    Messages:
    24
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    var_dump displays the contents of a variable.
    It returns a void(null) value so you can't use it in a echo/print statement nor assign it to a variable.
    In other words, it's not an ''r-value."
    
    $whatsit='2';
    echo '<pre>';
    echo 'Value is: ';
    var_dump($whatsit);
    echo '<pre>';
    
    // Outputs: Value is: string(1) "2"
    
    Code (markup):
     
    Last edited: Mar 17, 2011
    dgreenhouse, Mar 17, 2011 IP
  3. srisen2

    srisen2 Peon

    Messages:
    359
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    just do
    echo "valu is: $whatid";
     
    srisen2, Mar 17, 2011 IP