0
Following.
When I want to use something, for example, on the index, I want to pull a class to make an object, right?
Imagine the class is like this:
<?php
class Testando{
//Meu codigo aqui
}
?>
Ai, I have my index:
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<?php
require'Testando.class.phg';
$Teste = new Testando;
?>
</body>
</html>
Alas now, I have my second class, let’s suppose.. :
<?php
//Aqui eu não precisaria de um require/include da class Testando?
class EuTestei extends Testando {
//Meu codigo aqui
}
?>
Ali, where I commented, in the second class, would not need to include/require? Put here, testing, it not from error. But how does she find this class?
Are you using namespace? if you are using autoload it is not necessary to give include/require..
– wDrik
autoload I use, but do not understand, how that class extends to another, and I have not used require.
– Lucas de Carvalho
If this second file was also included in
index.php
, PHP finds the class because it was loaded inindex.php
through the firstrequire
. When you do therequire
orinclude
, for PHP is as if all the codes were written in the same file, so the classTestando
would be implemented before classEuTestei
, so it works. Ifindex.php
you giverequire
only the second file, so yes, you will need to give therequire
from the first where you commented.– Woss
I recommend you to study and understand how it works and what the autoload is for, because it already makes the complete load of all classes, and where you give a new in the object there already have all the classes of the system loaded.
– wDrik
I get it, Anderson, if you want to put the answer, then I mark it as you accept!
– Lucas de Carvalho
Thank you too Drik
– Lucas de Carvalho