php7 variable declarations in code, not in functions

General discussion on PHP
Post Reply
ivo8967
Posts: 1
Joined: Sat Nov 28, 2015 7:11 pm

php7 variable declarations in code, not in functions

Post by ivo8967 » Sat Nov 28, 2015 7:22 pm

I am a new php user. php sems awesome on some dimensions, and frustrating on others. at least since BASIC, all my languages except php have allowed me to predeclare my variables. Is there a hack to allow non-functional declarations (so my own code analyzer can then look for potential uses of variables that have not been declared)? I am even contemplating putting them in comments so I can check. (I do know that I can force runtime errors on undeclared variables.)

I have been bitten many times by slight misspellings in php. right now, even if declarations were wholly non-functional, for my own program-reading sake, I would love to declare "int $x;" or better yet "int $x=0;" . I am looking at php7, and php7 seems to allow declaration in function arguments, but I see no mention of declaration in the program code itself. is there a rationale to this?

regards,

/iaw

Post Reply