Hi everyone,
Throughout this website (and others), I have noticed people posting code in an absolute mess.
I have searched this site for a thread like this, and couldnt find one.
So therefore i have devised a quick example of good ways to space your code using tabs, in order to make it more readable.
I believe that people will get a much better response to their questions if they format their code to be more readable, like so:
An example of how to correctly space out a function:
PHP Code:
// Correctly spacing a function with tabs to make it readable.
function foo($bar)
{
// Use a coment to tell us what the block below is doing.
if ($bar == true)
{
$something = true;
}
return $somthing;
}
An example of a good way to space out a class:
PHP Code:
// Correctly spacing a class with tabs to make it readable.
class foo
{
public $somthing;
function __construct()
{
// Constructor
}
public function bar($bool)
{
if ($bool == true)
{
$this->something = true;
}
return $this->something;
}
}
Every time you open a new curly brace "{", add an extra tab, this will enable us to read code more easily and also you will know which brace is closing which blocks of code.
Bye for now.
Hi everyone,
Throughout this website (and others), I have noticed people posting code in an absolute mess.
I have searched this site for a thread like this, and couldnt find one.
So therefore i have devised a quick example of good ways to space your code using tabs, in order to make it more readable.
I believe that people will get a much better response to their questions if they format their code to be more readable, like so:
An example of how to correctly space out a function:
PHP Code:
// Correctly spacing a function with tabs to make it readable.
function foo($bar)
{
// Use a coment to tell us what the block below is doing.
if ($bar == true)
{
$something = true;
}
return $somthing;
}
An example of a good way to space out a class:
PHP Code:
// Correctly spacing a class with tabs to make it readable.
class foo
{
public $somthing;
function __construct()
{
// Constructor
}
public function bar($bool)
{
if ($bool == true)
{
$this->something = true;
}
return $this->something;
}
}
Every time you open a new curly brace "{", add an extra tab, this will enable us to read code more easily and also you will know which brace is closing which blocks of code.
Bye for now.
|
|
Search Webmaster Help and Solution
PHP Syntax FormattingRelated ItemsQuery failed: connection to localhost:3354 failed (errno=111, msg=Connection refused). |
