Skip to main content
Rob W's user avatar
Rob W's user avatar
Rob W's user avatar
Rob W
  • Member for 9 years, 6 months
  • Last seen more than 1 year ago
About

Developing while learning and helping others.

Top PHP issues I see on SO and my suggestions:

  1. Stop using mysql_* functions. They are deprecated. Instead, look into using PDO along with binding values. Be aware that bindValue and bindParam work differently.
  2. Stop using time stamps. Use the DateTime object instead. Convert all of your time stamps in tables to the DATETIME type as well. You'll no longer have to worry about which PHP architecture you're on and you'll have a plethora of functionality readily available instead of writing your own.
  3. You can pass external variables into a closure's scope, along with the ability to modify it (if passed by reference using &), by using the use keyword. Example:

$externalVar = 10; print_r(array_map(function($value) use (&$externalVar) { $externalVar++; return $value * $externalVar; }, range(1, 10)));

  1. Use CSRF tokens in your forms! And clear them after single use! Old laravel example
  2. If Google PageSpeed docks your score for analytics, then cheat back!
  3. You can't parse [X]HTML with regex. Because HTML can't be parsed by regex. Regex is not a tool that can be used to correctly parse HTML.
Badges
This user doesn’t have any gold badges yet.
This user doesn’t have any silver badges yet.
2
bronze badges
0
Score
2
Posts
100
Posts %
0
Score
1
Posts
50
Posts %
0
Score
1
Posts
50
Posts %
0
Score
1
Posts
50
Posts %
0
Score
1
Posts
50
Posts %
0
Score
1
Posts
50
Posts %
Top posts