Articles â†’ PHP â†’ Value Of Value In PHP

Value Of Value In PHP









$$abc=”xyz”;
$xyz=5;




<?php
Echo $$abc; // this will display 5
Echo ${$abc} //another way of interpreting the same thing




<?php
$expected = array(
    'name',
    'email',
    'comments'
);
$required = array(
    'name',
    'comments'
);
$missing = array();
foreach ($_POST as $key => $value)
{
    // assign to temporary variable and strip whitespace if not an array
    $temp = is_array($value) ? $value : trim($value);
    // if empty and required, add to $missing array
    if (empty($temp) && in_array($key, $required))
    {
        $missing[] = $key;
    }
    elseif (in_array($key, $expected))
    {
        // otherwise, assign to a variable of the same name as $key
        $
        {
            $key
        } = $temp;
    }
}
?>



Posted By  -  Geetanjali
 
Posted On  -  Saturday, January 16, 2016

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250