Answer the question
In order to leave comments, you need to log in
How to connect a trait?
why can't my class find the trait?
I sort of understood the theme of the trait. But when it came to practice, I simply could not connect the trait to the class, to put it mildly.
My folder structure was like this:
1.index.php
2.main.php(class)
3.single.php(train)
index.php
<?php
require_once 'main.php';
?>
<?php
/**
*
*/
class main
{
use single;
}
?>
<?php
trait single{
}
?>
Fatal error: Trait 'single' not found in C:\OSPanel\domains\text\public\main.php on line 9
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question