0

im just install php on my machine without installing LAMP,

the problem is when I miss the semicolon, the terminal doesn't show any error I already do some research but i have no clue about this, Is there any tools or tips to make my terminal scream when I have an error?

enter image description here

enter image description here

1
1

You don't see any error messages because the semicolon in this specific case is optional. It is because it's right before the closing php tag. Missing it in this location is still acceptable (even if not recommendable) syntax.

I took this info from here, then followed the link to the php documentation's corresponding page.


If you want to rely on this output from the development php server, you can do an extra step to ensure that you really don't miss anything, by using the error_reporting() function.

Putting these lines

ini_set('display_errors', 1);
error_reporting(E_ALL);

at the beginning of your script will ensure that even the smallest concerns will get printed in the console.


If you are learning php and using the development server to sharpen your skills, you could permanently enable these adjustments (so that you don't have to remember to put the above snippets in all your scripts).

For this, you need to find the php interpreter's configuration file, which is called php.ini.

Putting the following line in any of your scripts

phpinfo();

and subsequently looking at the output in a browser will summarize the configuration in a graphical fashion. The php.ini file's location is in the row labelled with: "Loaded Configuration File".

An alternative way would be issuing the command in terminal

php --ini

with similar results.

You can now open this file in an editor (sudo will be necessary to save the file, if it's in a system directory), search for the lines starting with error_reporting and display_errors, and edit them to your liking.

Right in php.ini itself, a handy in-line documentation will precede these lines, explaining the exact values and syntax you may use.


Depending on the progress you make in authoring applications, relying on the php development server's output for debugging may soon prove itself unsatisfactory.

For debugging done proper (and benefit from "entire new dimensions" of possibilities), one could consider installing and using a dedicated IDE (Integrated Development Environment), like PhpStorm or Apache Netbeans, and learn the ins and outs of debugging with these applications.

Not the answer you're looking for? Browse other questions tagged or ask your own question.