Path: csiph.com!aioe.org!news.mixmin.net!news.unit0.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Alessandro Pellizzari Newsgroups: it.comp.www.php Subject: Re: testare pagina con errori Date: 24 Jan 2017 20:59:35 GMT Lines: 32 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: individual.net vtWEUIYd3hiitOnIIyplkAeaWImaNKp2vbaAdfANjjrcYilzc= Cancel-Lock: sha1:22eTSc1eet08JwSKcksknugTu6I= User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) Xref: csiph.com it.comp.www.php:21404 Il Mon, 23 Jan 2017 21:02:03 +0100, alex ha scritto: > + cat test.php file_get_contents('http://local/index.php'); > echo false !== strpos($page, "Helo") ? 'ok' : 'error'; > echo "\n"; > > + php test.php ok > > Apparentemente il test sembra superato, ma se apro il browser e digito > http://local/index.php mi esce Notice: Undefined variable: abc in > index.php on line 2 Il problema รจ che stai testando la cosa sbagliata. Quando usi uno stream verso http stai testando il webserver, non lo script PHP. Nel tuo caso non stai nemmeno tanto testando lo script, quanto il parser (infatti ricevi un warning di variabile non dichiarata, non un risultato sbagliato). In pratica i test dovrebbero testare che dato un input tu riceva un certo output. Se vuoi testare il parser di PHP devi usare xdebug, che appunto si inserisce nel processo di parsing e lo analizza. Oppure, tranne che per i fatal error, usare un error_handler come dice Leonardo. Bye.