Thread: Correct Coding
View Single Post

  #7 (permalink)  
Old 08-07-2003
Roger B.A. Klorese
 
Posts: n/a
Default RE: [PHP] Correct Coding

> Could you explain a little better why this would make things better?
>
> I don't understand how this would improve things.



> > Concerning the $Task == "Add", I'd like to make a comment. It can
> > be a wise decision to compare your variables with strings like:
> >
> > if ("Add" == $Task)
> >
> > This can help preventing typo's like:
> >
> > if ($Task = "Add")


$Task = "Add" (typo'd for $Task == "Add") would assign the value,
clearly not your intent.

"Add" = $Task would be an illegal assignment to a constant, so your
error would be detected.


Reply With Quote