Tips for using the PHP function require ()

Source: Internet
Author: User

When you use the PHP function require () to include an external PHP file, as long as the PHP file is executed, the content of the external file will be included in the PHP file. When an error occurs for the contained external file, the system will prompt an error and stop executing the PHP file.

Example:

Code for calling the config. inc file:

 
 
  1. <? Php
  2. Echo "this is the called content: Hello! ";
  3. ?>

The program code of the current script example01.php:

 
 
  1. <? Php
  2. Echo "example of code reuse :";
  3. Require ('config. inc ');
  4. // Call another file config. inc,
    Output the content in config. inc.
  5. Echo "implemented using the require function.";?>

Instance location: mrsl4example01. php

Result: code reuse example: this is the content called by the PHP function require (): Hello! Implemented using the require function.


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.