Re: very weird PHP behaviour...

From: Date: Wed, 14 Nov 2001 18:37:25 +0000
Subject: Re: very weird PHP behaviour...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-74629@lists.php.net to get a copy of this message
try this: function Upload($source_file,$source_filename,$dest_dir,$allowed_types=array(), $upload_errmsg="") { if( count($allowed_types) ) { if(!in_array(ArquivoExt($source_filename),$allowed_types)) { ?>O arquivo <?=$source_filename?> não está entre os tipos autorizados<? return false; } } ... some more code here .. return true; } Jim ----- Original Message ----- From: "Christian Dechery" <cdechery@easynet.com.br> To: <php-general@lists.php.net> Sent: Wednesday, November 14, 2001 8:34 AM Subject: [PHP] very weird PHP behaviour... I don't know what it is... but PHP is acting very weird today... or I am becoming crazy... can anyone tell me which one? I have this function: function Upload($source_file,$source_filename,$dest_dir,$allowed_types=array()) { global $upload_errmsg; if( count($allowed_types) ) { $file_ext=ArquivoExt($source_filename); $ext_found=in_array($file_ext,$allowed_types); //die("source=$source_filename"); //var_dump($ext_found); //die; if( !$ext_found ) { $upload_errmsg="O arquivo \"$source_filename\" não está entre os tipos autorizados"; //die("errmsg=$upload_errmsg"); return false; } } ... some more code here .. return true; } the first crazy behaviour is... I use a test file called something.jpg, ArquivoExt() returns me the extension of a given filename, in this case "jpg". $allowed_types contains "gif","jpg" and "png" so that in_array() should return true... and it does... but get this... if I uncomment that var_dump() guess what it outputs? bool(true) bool(false) very weird... how can one var_dump() call gives me two outputs? This double output doesn't occur if I uncomment the "die" after the var_dump(). It only outputs bool(true) in that case. Now for the second weird behaviour... since no matter what, $ext_found will always be false (due to the previous weirdness) it will always enter the IF... but the weird thing is when the caller of Upload() prints $upload_errmsg it only outputs: O arquivo "" não está entre os tipos autorizados where is the filename? I've checked it tons of times... If I uncomment the second die, right after the $upload_errmsg assignment, it outputs ok, with the filename. Now, can someone explain me this VERY WEIRD behaviour?? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#74629) next »