How to do syntax checking using PHP ? Last Updated : 21 Sep, 2021 Comments Improve Suggest changes Like Article Like Report Syntax checking is one of the most important tasks in programming. Our compiler checks our code and shows relevant errors if there is any in the code i.e. compile time, run time, syntax, etc. We can do the same thing i.e. syntax checking in PHP. In this article, we are going to learn how we can do syntax checking in PHP. The syntax is basically a set of rules that defines the structure of a programming language. We can not manually change the syntax and we have to follow the rules of the language. Syntax: php -ln filename We can use --syntax-check in place of -ln, it is more readable. php --syntax-check filename It returns "No syntax errors detected in <filename>" if the provided PHP file has no syntax errors and passed the syntax check. Otherwise, it returns "Errors parsing <filename>" if there is a syntax error in the PHP file. The "-l" or "--syntax-check" argument performs a syntax check on the given PHP file. Example 1: The following PHP Code is without Syntax error. It finds the sum of two numbers. PHP <?php // First number $x = 10; // Second number $y = 20; // Sum of two numbers $c = $x + $y; // Displaying the sum echo "Sum is: ", $c; echo "\n" ?> Output Sum is: 30 Command for syntax checking: php -ln /home/rich/Documents/geeks/geek.php Output: No Syntax Error Example 2: In the above code, we simply replaced the "Sum: ", $z; with "Sum:, $z; then it throwing a syntax error. PHP <?PHP // First number $x = 15; // Second number $y = 30; // Sum $z = $x + $y; // Displaying sum echo "Sum:, $z; echo "\n"; ?> Command to do syntax checking: php -ln /home/rich/Documents/geeks/geek.php Output: Syntax Error Comment More infoAdvertise with us Next Article How to do syntax checking using PHP ? R rriicchhaa Follow Improve Article Tags : Web Technologies PHP Blogathon Blogathon-2021 PHP-Questions +1 More Similar Reads How to check for empty string in PHP ? In this article, we will see how to check for empty string in PHP. String is a set of characters. A string is said to be empty, if it contains no characters. We can use empty() function to check whether a string is empty or not.here we have some common approachesTable of ContentUsing empty() functio 4 min read PHP to check substring in a string In this article, we will see how to check the substring in a string. We are given two strings & we have to check whether the second string is a substring of the first string or not using PHP built-in strpos() function. This function is case-sensitive, which means that it treats upper-case and lo 2 min read How to check for errors in HTML ? HTML5 is easy to understand and it's not compiled into different forms before the browser displays it. In any code, 2 types of errors are possible: Syntax error: Incorrect syntax leading to compile time error in other languages.HTML have no affect of syntax error.Logical error: Syntax is correct but 2 min read How to check if a String Contains a Substring in PHP ? Checking whether a string contains a specific substring is a common task in PHP. Whether you're parsing user input, filtering content, or building search functionality, substring checking plays a crucial role.MethodsBelow are the following methods by which we can check if a string contains a substri 1 min read How to check a string starts/ends with a specific string in PHP ? In this article, we are going to learn how to check that a given string is starting or ending with a given specific string in PHP.We require the use of XAMPP, Netbeans to run this code.Input: "Geeks For Geeks"Starting with: "G"Output: "Geeks For Geeks Starts with String G"In PHP version 8+, there ar 2 min read How to Test PHP Code With phpUnit? Testing PHP code is a critical aspect of software development, ensuring that applications function as intended and maintain their integrity over time. PHPUnit stands out as a premier testing framework for PHP, empowering developers to create comprehensive test suites and validate their code effectiv 4 min read How to run PHP code in Brackets ? Brackets is a platform where HTML, CSS, JavaScript coding can be done. Editing these types of codes is very easy in Brackets. Pre-requisite for implementing PHP codes in Brackets: Install any local server in your machine like - Wamp, Xampp, or Mamp.Install Brackets. Features: It is platform-independ 2 min read How to Get PHP Configuration Information using phpinfo()? The phpinfo() function in PHP gives us the details about the PHP version and configuration installed in our system. To check the Configurations and Versions, a simple PHP script can be used. The script consists of a PHP function called "phpinfo()" which outputs information about PHP's configuration. 2 min read Getting Started with PHP PHP (Hypertext Preprocessor) is a powerful scripting language widely used for web development. Whether you're looking to create dynamic web pages, handle form data, interact with databases, or build web applications, PHP has you covered. In this guide, we'll take you through the basics of PHP, cover 7 min read How to validate and sanitize user input with PHP? Data validation is an integral part of web development, especially while working with forms where the user first enters their personal data and then sends that to the database. Data sent in an invalid format can cause DBMS security problems. Hackers often use SQL injections to insert malicious SQL c 4 min read Like