I have no idea what the problem is PHP CLI

Written by James McDonald

June 11, 2016

Trying to do some PHP tutorials using vim and running php from the command line and I get…. nothing back.

If it’s a syntax error (e.g. a missing line ending ; ) then no reply at all. If the syntax is correct and it’s something else then the error isn’t displayed

Apparently PHP CLI is muted by default.

So this link shows the answer which is:

php -d display_errors <script_filename.php>

So the silence is now throwing the Catchable fatal error duva:

php -d display_errors class.php 
This is a test of "TestClass" test class
object(TestClass)#1 (1) {
  ["prop1"]=>
  string(16) "My Test Property"
}
My Test Property from TestClass

Catchable fatal error: Object of class TestClass could not be converted to string in /Users/jmcd/class.php on line 37

Instead of uninformative silence:

php class.php 
This is a test of "TestClass" test class
object(TestClass)#1 (1) {
  ["prop1"]=>
  string(16) "My Test Property"
}
My Test Property from TestClass

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.

You May Also Like…

Squarespace Image Export

To gain continued access to your Squarespace website images after cancelling your subscription you have several...

MySQL 8.x GRANT ALL STATEMENT

-- CREATE CREATE USER 'tgnrestoreuser'@'localhost' IDENTIFIED BY 'AppleSauceLoveBird2024'; GRANT ALL PRIVILEGES ON...

Exetel Opt-Out of CGNAT

If your port forwards and inbound and/or outbound site-to-site VPN's have failed when switching to Exetel due to their...