How to use a custom function file to override a function in another php

Source: Internet
Author: User
How to use a custom function file to rewrite the function files in another php post, which was last edited by qq37431300 at 2014-01-1610: 28: 54 in order not to modify the program's system file, this prevents files modified after the upgrade from being overwritten during the upgrade. Therefore, you want to create a new custom function library file: extention. how does ph rewrite functions in another php with a custom function file?
At last, this post was edited by qq37431300 at 10:28:54 to avoid modifying system files of the program. This prevents files modified after the upgrade from being overwritten during the upgrade, so I want to create a new user-defined function library file: extention. php: include this extention when the system is running. php. you can modify the system functions in php in extention. write your own functions in php.

For example
There are three php files
A. php system library file cannot be modified
Extention. php custom function library file, add and modify at will
Result. php calls the method file in the function library

A. php
Function show ()
{
$ Str = 'This is ';
Return $ str;
}

Extention. php I also wrote a show () function in it. I want to modify the show () method in a. php.
Function show ()
{
$ Str = 'This is my extention ';
Return $ str;
}

Result. php includes the above two php files and calls the show () method.
Include 'A. php ';
Include 'extention. php ';

$ Result = show ();
Echo $ result;

In this way, the Cannot redeclare error will be reported when you access result. php.

I found a document on the Internet and said I could use a namespace, but it seems that the effect is not what I want.
I don't want to touch the system's function library file, such as. php; only modify my extention. php user-defined function library file, so that. modify the functions in php. I don't know if I can do it? Share: More

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.