After a long search, I finally found the reason, not the PHP version [], that I wrote use in the methods of the class.
This thing cannot be used independently of the class, otherwise it would be considered a namespace.
The test example is as follows
// Trait.php trait CustomerFunctionsTrait { public function plus ( $a = 1, $b = 1 ) { echo $a + $b; } public function minus ( $a = 5, $b = 1 ) { echo $a - $b; } } // Test.php include './Trait.php'; class MyTest { use CustomerFunctionsTrait; public function plus () { // use CustomerFunctionsTrait; //This is where I made a mistake, writing use into the method body -!!!! echo 'str'; } } $n = new MyTest; $n->minus();
Read More:
- PHP: How to parse MHT file into HTML
- [Solved] PHP post Datas json_decode Error: 4 JSON_ERROR_SYNTAX
- Error during session start; please check your PHP and/or webserver log file and configure your PHP
- PHP use __Sleep() and __wakeup() method serializes the object
- Mac PHP Fatal error: Class ‘Memcache’ not found
- PHP error in Windows: class’ mysqli ‘not found
- PHP Error Object of class mysqli could not be converted to string in
- Laravel-admin php artisan admin:install error reporting problem solution
- PHP: The Difference between \Throwable, \Error and \Exception
- How to Hide index.php
- [PHP] Solve PHP Call to undefined function ldap_connect()
- [Solved] PHP Error: Warning: file_get_contents(): Failed to enable crypto
- [PHP] Solve the limitation of uploading files in nginx php 413 Request Entity Too Large
- [Solved] PHP installation Phalcon expansion error
- Mac: Where is php.ini Location
- PHP php-config is not installed error in ubuntu 16 [How to Solve]
- PHP large file upload error 413: request entity too large [How to Solve]
- HTML + PHP inline execute JavaScript Error [How to Solve]
- php_network_getaddresses: getaddrinfo failed (How to Fix)
- laravel The Process class relies on proc_open, which is not available on your PHP installation.