Reputation: 10844
I am a newbie to php. I am working on a existing wordpress site. I want to print the values of a variable $post as output. What is the equivalent of Java's System.out.print in php.
While googling i found the same, system.out.print for php but its not working.
-- Thanks
Upvotes: 2
Views: 10544
Reputation: 2282
You can use echo
to print something: docs
$_POST
is an array, if you want to examine its value for debug purposes use var_dump
(docs):
var_dump($_POST);
To access array's elements, use square brackets: $_POST['index']
. PHP arrays may be associative, which means they are indexed not only by numbers, but also by strings. $_POST
is a pure associative array, indexed only with strings.
To print POST parameter called username
use this code:
echo $_POST['username'];
or
echo($_POST['username']);
Both will work because echo is not a function, but a language construct (see docs linked above).
Upvotes: 5
Reputation: 207891
PHP's echo construct is probably what you want.
<?php echo $_POST['variable']; ?>
where variable
is the name of the form element.
Upvotes: 0
Reputation: 13397
printf("var = %s", $var);
or
echo $var;
or (for objects, arrays, etc)
print_r($_POST);
or
var_dump($_POST);
Check php.net for more!
Upvotes: 1