Answer the question
In order to leave comments, you need to log in
How to write php code correctly and beautifully?
Today I touched upon the issue of cleanliness and literacy of the code, meaning its readability. For example:
if (isset($apples)) {
echo $apples;
}
else {echo "Переменная удалена";}
if (isset($apples)) {
echo $apples;
}
else {
echo "Переменная удалена";
}
Answer the question
In order to leave comments, you need to log in
There are tons of manuals for different projects besides the PSR-2 mentioned here:
https://make.wordpress.org/core/handbook/best-prac...
https://symfony.com/doc/current/contributing/code/ ...
https://framework.zend.com/manual/2.4/en/ref/codin...
https://www.drupal.org/docs/develop/standards/codi...
Plus in each team can be your own rules.
So the style of code design depends on which framework or CMS you use or in which team you work.
If you are writing something completely independent, then PSR-2 is a good choice, but using it in a project with its own established rules can be a strange decision.
PS I will add that there are tools for automatically correcting the design that are not tied to the IDE (for examplecs.sensiolabs.org ), so you can write whatever you want and then customize everything to some standard.
There is such a way to write, starting with PHP 7:
php.net/manual/ru/language.operators.comparison.ph...
<?php
echo $apples ?? "Переменная удалена";
For php there is a PSR standard.
You can install php storm and it will align you properly in PSR using CTRL + L
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question