There are require
and include_once
as well.
So your question should be…
- When should I use
require
vs.include
? - When should I use
require_once
vs.require
The answer to 1 is described here.
The require() function is identical to include(), except that it handles errors differently. If an error occurs, the include() function generates a warning, but the script will continue execution. The require() generates a fatal error, and the script will stop.
The answer to 2 can be found here.
The require_once() statement is identical to require() except PHP will check if the file has already been included, and if so, not include (require) it again.
Related Posts:
- How do I run a file on localhost?
- “Fatal error: Cannot redeclare function”
- Replace ' and similar html codes with their correspondent character?
- How to prevent the “Confirm Form Resubmission” dialog?
- navigate back with PHP form submission
- How to fix “Headers already sent” error in PHP
- Whoops, looks like something went wrong. Laravel 5.0
- “Notice: Undefined variable”, “Notice: Undefined index”, and “Notice: Undefined offset” using PHP
- http://localhost:80 is not working on running Apache server through UniServer ZeroXIII
- PDOException SQLSTATE[HY000] [2002] No such file or directory
- How do I get PHP errors to display?
- Get the full URL in PHP
- How do I check if a string contains a specific word?
- How to force file download with PHP
- How to Set Category Page as Home Page in Prestashop
- Getting an error when I visit http://localhost
- How can I find my php.ini on wordpress?
- PHP + curl, HTTP POST sample code?
- PHP random string generator
- What are the differences in die() and exit() in PHP?
- How to call a JavaScript function from PHP?
- Error 500: Premature end of script headers
- Cookies vs. sessions
- Expected status code 200 but received 500
- Can you “compile” PHP code and upload a binary-ish file, which will just be run by the byte code interpreter?
- Invalid argument supplied for foreach()
- Remove the last character from a string
- Multiple file upload in php
- How to prevent Browser cache for php site
- what does a .php?id=&value=value means?
- Setting up a PHP interpreter in PhpStorm
- When should I use ‘self’ over ‘$this’?
- Get Current URL in Magento and show something
- php create object without class
- Creating a search form in PHP to search a database?
- Weird PHP error: ‘Can’t use function return value in write context’
- How do I get a YouTube video thumbnail from the YouTube API?
- When to generate a new Application Key in Laravel?
- “Connection for controluser as defined in your configuration failed” with phpMyAdmin in XAMPP
- Call to undefined method mysqli_stmt::get_result
- How to call function of one php file from another php file and pass parameters to it?
- SQLSTATE[HY093]: Invalid parameter number: parameter was not defined
- Is it possible to run .php files on my local computer?
- What does it mean to escape a string?
- Creating default object from empty value in PHP?
- MAMP “Apache couldn’t be started because port is in use.” AND “Can’t connect to local MySQL server through /tmp/mysql.sock
- Php include not working? function not being included
- Send attachments with PHP Mail()?
- PHP mail function doesn’t complete sending of e-mail
- Convert php array to Javascript
- Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by all
- phpMyAdmin ERROR: mysqli_real_connect(): (HY000/1045): Access denied for user ‘pma’@’localhost’ (using password: NO)
- Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in
- Convert DateTime to String PHP
- Xampp Access Forbidden php
- SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens on line 102
- File attachment with PHPMailer
- What does MYSQLI_NUM mean and do?
- Fatal Error: Allowed Memory Size of 134217728 Bytes Exhausted (CodeIgniter + XML-RPC)
- Laravel 5 Clear Views Cache
- phpinfo() is not working on my CentOS server
- XAMPP, using port:81, cannot run localhost:81/mywebsite
- ERROR: SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it
- What is the MM/DD/YYYY regular expression and how do I use it in php?
- Warning “Do not Access Superglobal $_POST Array Directly” on Netbeans 7.4 for PHP
- How to integrate WordPress with Angular 8 for website?
- Fatal error: Maximum execution time of 30 seconds exceeded
- cURL request in Laravel
- PHP array printing using a loop
- How to send to BCC address when using PHPMailer to format MIME message for Gmail API?
- Call a REST API in PHP
- Fatal error: Call to a member function query() on null
- Is there any way to test PHP locally without installing a server?
- How can I write php code in notepad++?
- PHP Redirect with POST data
- Getting the screen resolution using PHP
- PHP: fopen() Permission denied
- How should I be setting browscap.ini file
- CodeIgniter: Unable to connect to your database server using the provided settings Error Message
- Returning JSON from a PHP Script
- How to run a PHP function from an HTML form?
- Can I store images in MySQL
- MySQL Daemon Failed to Start – centos 6
- How to remove index.php from WordPress site URL
- How to generate .json file with PHP?
- Call to a member function on a non-object [duplicate]
- Generate PDF from HTML PHP
- Call to a member function fetch_assoc() on boolean in
[duplicate] - How to use Memcached with PHP7?
- Remove empty array elements
- select count(*) from table of mysql in php
- Auto increment in phpmyadmin
- Undefined index with $_POST [duplicate]
- file_get_contents() how to fix error “Failed to open stream”, “No such file”
- wordpress menu dropdown item not showing after first dropdown
- Include WP_Query in my own PHP file?
- Include a external PHP file into a WordPress Custom Template
- How do I fetch a data from an external database into my wordpress homepage
- How do I fetch a data from an external database into my wordpress homepage
- php “use” not working in template [closed]