Skip to content

Tag: syntax

PHP weird curly brace syntax?

Does anyone know if PHP has an alternate curly brace syntax? I’ve come across a PHP file with a weird syntax I’ve never seen before. It’s being used in a WordPress theme. Here’s an example of the …

expecting statement -php syntax | if-else

I get critical error.phpstorms says that expecting statements.I couldnt find a solution Answer You cannot “interrupt” the PHP code after the closing { of the if and before the else keyword. Cleaned up version: To avoid such errors, try learning and following a coding standard, e.g. PSR-12. Since y…

PHP Difference between array() and []

I’m writing a PHP app and I want to make sure it will work with no errors. The original code: Would the following work with no errors or is not recommended for some reason? Are there any difference? I’ve looked again the data about array() and the short array method with square brackets [] in PHP.…

Validate PHP syntax in VIM

I would like to know how if it’s possible to validate if a PHP file is valid in VIM without closing VIM every time? Thank you Answer You can execute shell commands in vim. This is the same as calling php -l filename.php from the shell: I have this mapped into my ~/.vim/after/ftplugin/php.vim file so tha…