Extends Cakerequest, overriding the Is method _php tutorial

Source: Internet
Author: User
Background: cakephp development environment version is 2.3.8, the server's cakephp version is 2.3.5, test good code uploaded to the server after the total explosion of the following warning:

Warning (2): Strtolower () expects parameter 1 to is string, array given [core\cake\network\cakerequest.php, line 478< /c2>]

After comparison to 2.3.8 and 2.3.5 found, 2.3.8 is more than 2.3.5 function is the following code:

        < span="">(< span="">(< span="">< span="">< span="">< span="">(< span="">< /c17>  < span="">  ( < span="">  < span="">  < span="">  < span=""> (< span="">(< span="">)) > 0< span="">

Although the problem can be solved by directly modifying the files in Lib, it is decided to customize the cakerequest and rewrite the IS function, considering the problems of later escalation.
The process is as follows:

Add the following code to the app/config/bootstrap.php:

< span="">APP. ' Lib '. Ds. ' Network '. Ds. ' cakerequest.php '< span="">Error:  
Require APP. ' Lib '. Ds. ' Network '. Ds. ' appcakerequest.php ';

Create a new Network directory under the app/lib/directory and copy cakerequest.php of Coorey (lib/cake/network/) to this directory.

Then add appcakerequest.php to this directory:

 controller '. * * @package cake.networkAppcakerequest  Is ( ((=((, ' is '), (()) > 0 =((!(->_detectors[ =->_detectors[(([' Env '(([' Value 'Env[' env ']) ==[' Value '(([' Pattern '(BOOL)([' pattern '], env ([' Env '(([' Options '= '/' .('|',[' Options ']) . '/I '(BOOL)(, Env ([' Env '(([' Param '=[' Param '=[' Value ' (->params[]) ?->params[] ==:(([' Callback ']) &&([' Callback ' ([' Callback '], 

Edit app/webroot/index.php:

< span="">Dispatch (    new Cakerequest (),    new Cakeresponse ());  < span="">  < span=""> appcakerequest ( ),< span="">    < span="">      < span=""> cakeresponse (' charset ' = Configure::read ('< span="">app.encoding '< span="">

Done, the mistake no longer burst, I am a new cakephp, welcome to shoot bricks.

Reference: Http://stackoverflow.com/questions/8554536/extending-the-cakerequest-object

Finally spit the trough, today finally is to finish this project, six months ago should be invited by friends, take this cakephp website project,

Although the construction period is very easy, gave me a large half of the time, and the needs of friends are intermittent to me.

I've never been in touch with PHP before, let alone cakephp, and there is less data on cakephp, and many problems have to be answered in English or Japanese yahoo.

Sometimes I really want Shi's heart to have AH.

This is really a waste of their own time, and will never take this reverse telecommuting.

Do you have spare time instead of learning the knowledge you are interested in?

http://www.bkjia.com/PHPjc/753004.html www.bkjia.com true http://www.bkjia.com/PHPjc/753004.html techarticle Background: cakephp development environment version is 2.3.8, the server's cakephp version is 2.3.5, test good code uploaded to the server after the total explosion of the following warning: Warning (2): Strtolower () ...

  • Related Article

    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.