Its About A Year Ago Since I Started Learning Php, And Till Now I Probably Know Each And Every Aspect Of It Or At least Have Basic Knowledge Of It.
But Sometimes It Can Be Very Difficult To Find An Error In Your Code, Even Though You Know Line Number :p
So What I Thought Was To Collect All Those My Mistakes Or Blunder And Make A Blog Post About It, Some Of Then Are Logical But Most Are Because Of Syntax.
So Here Are My Top Five Mistakes Which I Usually Do While In Coding In Server Side, And I Feel Like Blind When I Phrase The Line Again N Again But Nothing Happens.
Top 5 Php Coding Mistakes
5.Missing SemiColons
Parse error:parse error in c:\me.php on line 2
One Of The Common Kind That Is Found On Many Of My Pages.
This Never Happen when I Code A Page From Start To End in One Shift
But One Shift Never Happens So This Error Often Happens :D
$test = 1
echo $test ;
Type : Syntax Error.
4.Greater Than Or Less Than
I Don't Know Weather This Happen With Me Only Or Its A Common One.
$i=5;
for($i=5;$i<=0;$i++){ echo "Lol!!"; }
You Can Easily Find Error In Above Code But If You Are Able to Find Above Error In A Page Of 1000+ Lines Then That Can Make A Difference. :p
Its A Kind Of Standard To Use Forward Looping But In Case I Need To Use Reverse Loop This Error Often Occurs.
Type : Logical Error.
3. Invisible Output
The Invisible Output is Hard To Find. This Normally Happen when im trying to use a Template And Inserting php snippet in it.
header(“Location: http://company.com”);
?>
You Will get A Error Like Header Already Sent. Best Way To Do Is To Write Php Header Before Any Html Tag.
Type : Syntax Error.
2. Not Enough Equal Signs
Everybody Has A Impact Of High School Math Like Equal to Is Represented By "=".
So in Some my pages This Normally Happens
if($i==5) becomes if($i=5) :p
So Now $i=5; And Its Always True :D
And fun part of it sometime im not able to find it , result in using alternative of it.
Type : Logical Error.
1. Making Fun Of Regular Expressions
Regular Expression is Something Which Is Hard To Learn Even A Perfect Logician Can Make A Mistake In It Rsulting Zero Match.
Even Though Im Getting Started With It But Most Of Time I'm Copying it.
Because As Soon As I Start Writing Regular Expression Every Thing Goes Right From My Side But When Running it Some Unexpected Error Come.
die("The End");
So Those Were Some Of My Mistakes When I'm Hanging On Server Side With Php.
If You Have Any Of Your Favorite One To Share Please Let It Be In Comments.
But Sometimes It Can Be Very Difficult To Find An Error In Your Code, Even Though You Know Line Number :p
So What I Thought Was To Collect All Those My Mistakes Or Blunder And Make A Blog Post About It, Some Of Then Are Logical But Most Are Because Of Syntax.
So Here Are My Top Five Mistakes Which I Usually Do While In Coding In Server Side, And I Feel Like Blind When I Phrase The Line Again N Again But Nothing Happens.
Top 5 Php Coding Mistakes
5.Missing SemiColons
Parse error:parse error in c:\me.php on line 2
One Of The Common Kind That Is Found On Many Of My Pages.
This Never Happen when I Code A Page From Start To End in One Shift
But One Shift Never Happens So This Error Often Happens :D
$test = 1
echo $test ;
Type : Syntax Error.
4.Greater Than Or Less Than
I Don't Know Weather This Happen With Me Only Or Its A Common One.
$i=5;
for($i=5;$i<=0;$i++){ echo "Lol!!"; }
You Can Easily Find Error In Above Code But If You Are Able to Find Above Error In A Page Of 1000+ Lines Then That Can Make A Difference. :p
Its A Kind Of Standard To Use Forward Looping But In Case I Need To Use Reverse Loop This Error Often Occurs.
Type : Logical Error.
3. Invisible Output
The Invisible Output is Hard To Find. This Normally Happen when im trying to use a Template And Inserting php snippet in it.
header(“Location: http://company.com”);
?>
You Will get A Error Like Header Already Sent. Best Way To Do Is To Write Php Header Before Any Html Tag.
Type : Syntax Error.
2. Not Enough Equal Signs
Everybody Has A Impact Of High School Math Like Equal to Is Represented By "=".
So in Some my pages This Normally Happens
if($i==5) becomes if($i=5) :p
So Now $i=5; And Its Always True :D
And fun part of it sometime im not able to find it , result in using alternative of it.
Type : Logical Error.
1. Making Fun Of Regular Expressions
Regular Expression is Something Which Is Hard To Learn Even A Perfect Logician Can Make A Mistake In It Rsulting Zero Match.
Even Though Im Getting Started With It But Most Of Time I'm Copying it.
Because As Soon As I Start Writing Regular Expression Every Thing Goes Right From My Side But When Running it Some Unexpected Error Come.
die("The End");
So Those Were Some Of My Mistakes When I'm Hanging On Server Side With Php.
If You Have Any Of Your Favorite One To Share Please Let It Be In Comments.
No comments:
Post a Comment