Error logging for PHP samples

Source: Internet
Author: User

In recent days in testing PHP MVC, find several examples from the web.

Learn this article first, http://www.cnblogs.com/q1ng/p/4529496.html

The title is the PHP MVC framework In-depth parsing , in fact, is the simplest, thanks to q1ng code.

With the foundation of the first article, learn the second article, http://www.cnblogs.com/foonsun/p/5788564.html

The title is PHP simple implementation of MVC, and the first one almost, the content went further. But is called simple realization, this man is very modest. Thanks for the Choshe code.

The first one was right, it went well, and the second article was wrong.

In the second section, the Views view in this lesson, the parameter is wrong, cannot open the page

The source code cannot be executed, prompting for a definition error, notice:undefined variable:

controller/democontroller.php
Class Democontroller
{
Private $data = ' Hello furzoom! ';
Public Function Index ()
{
echo ' Hello World ';
Require (' view/index.php ');
$view = new Index ();
$view->display ($data);
}
}//End of the class Democontroller
End of File democontroller.php

Change into

controller/democontroller.php
Class Democontroller
{
Private $data = ' Hello furzoom! ';
Public Function Index ()
{
echo ' Hello World ';
Require (' view/index.php ');
$view = new Index ();
$view->display ($this->data);
}
}//End of the class Democontroller
End of File democontroller.php

Note that $view->display ($data); $view->display ($this->data);

Remember, it's safer to use old-fashioned notation when doing class constructors.

The following code is in another tutorial, unable to execute, code error,

Address http://www.cnblogs.com/soundcode/p/6903826.html thanks to left 's code.

Class Test
{var $b;
function test () {$this->b=5;}
function Addab ($c) {return $this->b+ $c;}
}
$a = new test (); Echo $a->addab (4); Returns 9

Change it to the following.

Class Test
{var $b;
function __construct () {$this->b=5;}
function Addab ($c) {return $this->b+ $c;}
}
$a = new test (); Echo $a->addab (4); Returns 9

Error logging for PHP samples

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.