We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

prints in code

Hello everyone! More recently started learning framework. Made a small skeleton with tools. But I can not understand, how do I know the contents of the variable? For example here: https://github.com/uonick/ph-store/blob/master/app/models/users.php#L4 For example, I write here:


$new = 666;
print_r($new)

But it does not work. Just a white screen Tell me how to be?



58.4k
edited Dec '14

you must disable view to result, for example in controller

 $this->view->disable();


1.4k

And to do it every time? How i can then turn on / off developer mode (write a handler for example)



58.4k
Accepted
answer

This is just opnion . In file index.php you create function php look like

    unction d($object, $kill = true)
{
    echo '<pre style="text-aling:left">';
    print_r($object);
    if ($kill) {
        die('END');
    }
    echo '</pre>';
}

Then you call it

d($nice)


1.4k

Hey! Thanks for the answer! But it does not work. For sure I am doing something wrong =) Controller:

<?php

class IndexController extends ControllerBase{

    public function indexAction(){
        $this->view->disable();
    }

}

Model:


<?php

class Users extends \Phalcon\Mvc\Model{
    $var=6666;
    echo '<pre>';
        print_r($var);
    echo '</pre>';
}

White page =(

If I'm just doing a quick output - I just echo it then call exit() right after. Not a good permanent solution, but it's effective if all you need is something quick-n-dirty.



1.4k

whether it is necessary in this case to turn off the output to a template?



43.9k

    $var=6666;
    echo '<pre>';
        print_r($var);
    echo '</pre>';

that code should be located in the controller action you are calling ...



1.4k

This need is often needed in different parts of my code, it turns out that it is impossible to know most of the values of the code?