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

How to get rid of this error

Hi i use {{ uri.getBaseUri }} on my volt file. it work but Notice appear.

Notice: Undefined property: Phalcon\Mvc\Url::$getBaseUri in E:\wamp\www\kevin\phalcon\anotherphalcontest\app\cache\e__wamp_www_kevin_phalcon_anotherphalcontest_app_views_index_index.volt.php on line 2

here's my view/index/index.volt code:

{{ link_to(url.getBaseUri ~ "index/input", "Add") }}

my indexController.php code:

<?php

class IndexController extends ControllerBase
{

    public function indexAction()
    {

    }

    public function inputAction() {

    }

    public function listAction() {

    }

    public function addNewAction() {
        $a = new Users();
        //echo $this->request->getPost("name") . " " . $this->request->getPost("email");
        $a->name = $this->request->getPost("name");
        $a->email = $this->request->getPost("email");
        $a->save();
    }
}

where do i define this Phalcon\Mvc\Url::$getBaseUri

i know changing error_reporting(0) on index.php can remove this error. but i want to know if theres a proper way to do it. thanks in advance



5.0k
Accepted
answer
edited May '14

When using functions in volt use the () like a regular function.

{{ url.getBaseUri() }}

thanks sir but this is not working

What error are you getting now then?

Try: {{ url.getBaseUri() }}

this works for me

{{ link_to(uri.getBaseUri() ~ "index/input", "Add New") }}

Fatal error: Call to a member function getBaseUri() on a non-object in E:\wamp\www\kevin\phalcon\anotherphalcontest\app\cache\e__wamp_www_kevin_phalcon_anotherphalcontest_app_views_index_list.volt.php on line 15 Call Stack

You are using URI, you should be using URL.

Like this:

{{ url.getBaseUri() }}

ow i see. i use uri.getBaseUri() not url.getBaseUri()

its url not uri

thanks.

haha on my screen it same letters wtf. i think i need to calibrate my graphics. thanks

Out of topic:

how did you do that code block you did on your first comment ?

can you accept the answer?

  <?php

   require __DIR__ . '/vendor/autoload.php';

3 backticks, php and ending with 3 backticks.

edited May '14

php <?php echo "thank you"; ?>

nvm.. haha thank you



16.3k

@besingamkb this forum use markdown, find here and you can play with it.

or this one maybe https://daringfireball.net/projects/markdown/syntax

@sum nice info. thanks