Require and include

0

Hello, I have a question on the following:

Class: "Test1.php"

<?php
class Teste1{}...
?>
  • Ex1- include 'Test1.php'
  • Ex2- include_once 'test1.php'
  • Ex3- require_once 'Test1.php'

Is it possible to call test1 (in minuscule), as in Ex2? Will it work?

I've seen in some blogs that it's only in php 4, so it's not correct to be case sensitive, is that right?

Thank you

    
asked by anonymous 17.04.2018 / 17:22

2 answers

0

It works like this:

<?php
include_once "a.php"; // vai carregar o ficheiro a.php
include_once "A.php"; // vai carregar o ficheiro a.php novamente! (só no PHP4)
?>

This behavior has changed in PHP5. That is, the file is uploaded only once.

source: link

    
17.04.2018 / 17:37
0

On case-insensitive file systems, such as Windows, it makes no difference. However, Linux is case-sensitive !

From my experience, I used the files with the lowercase names and AutoLoader with PSR-4 loaded my files normally using even PHP 7.2 (Current). However, when running my project on Linux, also with PHP 7.2 , I had to rename my files attentively to case-sensitive .

Ideally, the files should always be case-sensitive, since it is possible to change the environment over time.

    
17.04.2018 / 17:49