Question

I have a WAMP server on Windows 7.

I have a php code like :

<html>
<head>
<script>
 var myvar;
 <?php include "myotherphp.php" ?> <!-- this put single line, like myvar="error"; or myvar="ok"; -->
</script>
<body>
...
<script>
if (myvar === "error") {
... do something ...
}
</script>
<body>

and the code for myotherphp.php do some calculation and do something like ...

<?php
...
echo 'myvar="error";
?>

myotherphp.php has tousand of lines code, but... when I did, as before on IIS - there was no problem, and I didn't get any exception, but I get the annoying code inserted automatically on code:

SCREAM: Error suppression ignored for
Notice: Undefined index: ...

It is unwanted code. 1. Is there any option not putting code (It is more annoying, and it makes other errors on my script, because due that code, my html isn't compiled properly. 2. I want put here the whole code (tousand of lines, including other php) , but I need a concept to compile my code properly.

I found phplint http://www.icosaedro.it/phplint/phplint-on-line.html, but I don't know whether this is good for apache, and the not online phplint. since line like:

required_once __DIR__ . "/mythirdphp.php";

will never compiled (due some security issue). It is not like jslint.com (which on my opinion much better and understoodable. I put tousands of lines on javascript, and managed to semi-compiled them with no error or warnings on jslint ...)

I need to understand this issue of lint and any buggy code, and any help will be appriciated. Need to be crossed platform compiled.

If there are other tools - let me know about.

Thanks :)

Was it helpful?

Solution

Undefined index errors are the result of bad PHP code like this (Just an example, not a complete list of possible causes)

$x = $_POST['some_variable']

But 'some_variable' is optional and in this case has not been passed to the script in the POST array.

The proper solution would be to correct the code by testing if the variable exists before using it.

$x = array_key_exists('some_variable'] ? $_POST['some_variable'] : '';

Alternatively if you have 1000's of lines of code to fix, you could just turn error reporting off by adding

error_reporting(0);

to the top of the script with all the bad code in. Its a dirty solution but may be your only option.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top