since I am using json, and ajax it's annoting I cn't pass the value on a valid json.
is there away to just return the value of var dump without it echo,being output to the browser.
e.g.
$data = 'my_data';
get_var_dump($data);//not real func
//should do nothing.
$get['data'] = get_var_dump($data);
$get['error']= false;
echo json_encode($get);
//should be something like
//{"data,"string(7) my_data","error":false}
or the print_r equivalent I just want to to be assigned to a var instead of outputting it.
or if ur a wordpress fan, difference between bloginfo('url'); and get_bloginfo('url'); should make it easier :)
PHP | var_dump() Function The var_dump() function is used to dump information about a variable. This function displays structured information such as type and value of the given variable. Arrays and objects are explored recursively with values indented to show structure.
print_r(variable, isStore) It is a built-in function in print_r in PHP that is used to print or display the contents of a variable. It essentially prints human-readable data about a variable. The value of the variable will be printed if it is a string, integer, or float.
echo and print are more or less the same. They are both used to output data to the screen. The differences are small: echo has no return value while print has a return value of 1 so it can be used in expressions.
The print and echo are both language constructs to display strings. The echo has a void return type, whereas print has a return value of 1 so it can be used in expressions. The print_r is used to display human-readable information about a variable.
Sure you can! To do that you will need two PHP buffer functions: ob_start
and ob_get_clean
. The first one starts buffering, when the second is getting value and cleaning buffer. Example:
ob_start();
var_dump($array);
$value = ob_get_clean();
print_r
has the option for a second parameter. When set to true, it returns the dump as an array instead of displaying it.
http://us2.php.net/print_r
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With