473,396 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Is there a setting or program for doing strict checking in PHP compilation?

Coming from an objectpascal background with strict type checking, I am
being driven nuts by PHP.

Stuff like using variables without declaring them, case sensitivity of
variables, getting true, false, 0, 1, "" mixed up, missing the $ before
variables etc is really slowing me down.

Is there a way to configure a run-time setting or interpreter setting
that will throw up warnings or declare an error if some of these issues
are present?

I really need an external lint type program or a run-time setting that
will highlight these issues in PHP.

/My

Jul 17 '05 #1
5 2161
my********@yahoo.co.uk wrote:
Coming from an objectpascal background with strict type checking, I am
being driven nuts by PHP.

Stuff like using variables without declaring them, case sensitivity of
variables, getting true, false, 0, 1, "" mixed up, missing the $
before variables etc is really slowing me down.

Is there a way to configure a run-time setting or interpreter setting
that will throw up warnings or declare an error if some of these
issues are present?

I really need an external lint type program or a run-time setting that
will highlight these issues in PHP.


Use === for a strict type checked comparison, and error_reporting(15) to
get the other stuff (or change the setting in your local php.ini or
httpd.conf files).

--
Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com
Jul 17 '05 #2
my********@yahoo.co.uk wrote:
Stuff like using variables without declaring them, case sensitivity of
variables, getting true, false, 0, 1, "" mixed up, missing the $ before
variables etc is really slowing me down.

Is there a way to configure a run-time setting or interpreter setting
that will throw up warnings or declare an error if some of these issues
are present?

I really need an external lint type program or a run-time setting that
will highlight these issues in PHP.


uninitialized variables will produce a 'NOTICE' exception. Solution would be
to specif error reporting (only) at the start of each script. Set to E_ALL
for testing, something less sensitive for production. Or write your own
error handler.

C.
Jul 18 '05 #3
Are there any examples of the above techniques?

Jul 21 '05 #4
At the beginning of your code, do this:

error_reporting(E_ALL);

when you check if a variable is false, rather than empty, to this:

if (flag === false)

if you want to check if something is storing an integer, you can do
type checking with:
is_integer(i) or is_int(i)

for the $ - your editor should help you identify these. I would
recommend PHP Eclipse.

Jul 21 '05 #5
talking about $, I missed it in all my examples, grrrr
flag should be $flag and i should be $i - sorry about that ... been
programming too much in other languages lately.

Jul 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Aaron Watters | last post by:
I'm doing a heart/lung bypass procedure on a largish Python program at the moment and it prompted the thought that the methodology I'm using would be absolutely impossible with a more "type safe"...
6
by: Roman Mashak | last post by:
Hello, All! I'm trying to set up macro: .... int main(int argc, char *argv, char *envp) { .... if ( argc > 1 ) { if ( strcmp(argv, "-d") == 0 ) {
2
by: Sam Sungshik Kong | last post by:
Hello! I studied C# a little bit and am trying to compare it with VB.Net. There's 'Option Strict' in VB.Net. I thought that if I turn it on, it is as strict as C# when checking types. See...
2
by: junlia | last post by:
Hi All, I am working on a project that acts as a bridge. It does some checking with post xml data, and then redirects the request to an appropriate page. However, we find that depends on the...
7
by: Jazz | last post by:
Hello, I am using VSNet 2003 and I am trying to programmatically detect if debug attribute in the compilation tag is true or false. How can I do this ? Thanks, Jazz
2
by: Justin | last post by:
I have set Option Strict On I also have Enum AssemblyLineStatus As Integer My question is how come there is no compilation error when I compile following code? If...
1
by: Jerad Rose | last post by:
I believe this issue is specific to ASP.NET. Why does VB.NET (2.0) ignore the project-level setting for Option Strict? I have the setting turned on in web.config: <compilation debug="true"...
1
by: ac.c.2k7 | last post by:
Hi All, While doing the cross compilation of pkg_config for directFB for MIPS target from i86 platform, i am getting the following error. "checking for extra flags to get ANSI library...
3
by: Squat'n Dive | last post by:
Does anyone have an idea why -fno-strict-aliasing is turned off when cross compiling? in configure generated for 2.4.4: case $GCC in yes) # Python violates C99 rules, by casting between...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.