Online PHP Coding Standards Fixer

An online tool to automatically fix PHP coding standards issues. You can also use it to make your code looks more beautiful.
http://phpio.net/tools/csfixer

For example:

Original code:

if($a > $b){ echo "a is bigger than b";
} else if ($a == $b) {   echo "a is equal to b";
} else {    echo "a is smaller than b";
}

Fixed code:

if ($a > $b) {
    echo 'a is bigger than b';
} elseif ($a == $b) {
    echo 'a is equal to b';
} else {
    echo 'a is smaller than b';
}

Welcome to the forums, @daniel9x.

You haven’t really said why you’re posting this here. (After all, a forum is a place for discussion, so it’s good to have a point to discuss. ) Is it your own site, or one which you’ve found useful?

1 Like

I have to say I find

if ($a > $b)
    echo 'a is bigger than b';
elseif ($a == $b)
    echo 'a is equal to b';
else
    echo 'a is smaller than b';

neater.

1 Like

It’s almost as if different people have different standards :fearful:

3 Likes

They do. eg. a small sample

https://make.wordpress.org/core/handbook/best-practices/coding-standards/css/
https://make.wordpress.org/core/handbook/best-practices/coding-standards/javascript/

https://pear.php.net/manual/en/standards.php

http://area51.phpbb.com/docs/30x/coding-guidelines.html
http://area51.phpbb.com/docs/31x/coding-guidelines.html

IMHO unless you are contributing to a project that has standards, or working with a team, the main thing is to try and be consistent.

2 Likes

Thank you. I will update the post.
I found it’s useful for newbie PHP developer like me :))

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.