Ask about general coding issues or problems here.

Moderators: gesf, Michalio

Post Reply
php-forum Active User
php-forum Active User
Posts: 32
Joined: Sat Dec 26, 2015 12:18 pm

I have a file (global.php) that used by many different other files in a project I'm doing. This file contains many things including connecting to a MySQL database as well as loading a php_serial_class.

So at the top of php file that needs these resources, I use

Code: Select all

In one of those other php files, I also have a function that I'm using that calls the php_serial_class:

Code: Select all

$read = $serial->readPort();
This throws an error:
PHP Fatal error: Uncaught Error: Call to a member function readPort() on string in /var/www/controlserial.php:370
Stack trace:
#0 /var/www/controlserial.php(104): checkInput('11111')
#1 {main}
thrown in /var/www/controlserial.php on line 370
Line 104 is the call to the function and Line 370 is the actual read call to the class

I assume this error is thrown as the function doesn't know about that class? If so, can I simply also load the include within the function or is there a better way to do it?
Post Reply