class IndexController extends \Phalcon\Mvc\Controller
{
public function indexAction()
{
$custom = "Custom variable";
var_dump($custom);
}
}
How to display the result not using the variables in the template?
P.S. The result of the Echo function is also suppressed. I understand that this is the wrong approach, but it is a quick way to debug the variables.
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. This function is also effective with expressions.
@JMTyler var_export returns a parsable string—essentially PHP code—while var_dump provides a raw dump of the data. So, for example, if you call var_dump on an integer with the value of 1, it would print int(1) while var_export just prints out 1 .
var_dump() displays values along with data types as output. print_r() displays only value as output. It does not have any return type. It will return a value that is in string format.
It's too simple. The var_dump() function displays structured information about variables/expressions including its type and value. Whereas The print_r() displays information about a variable in a way that's readable by humans. Example: Say we have got the following array and we want to display its contents.
if you don't see output from controller check if in your template file you have this line:
{{ content() }}
you can use php's var_dump in any place of your code:
var_dump($var);exit;
exit; is to stop anything what happens after this line.
You can also dump your vars in volt's template with volt's function:
{{dump(var)}}
dump() is same as var_dump() Here are some more useful volt functions:
http://docs.phalconphp.com/en/latest/reference/volt.html#functions
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