Function hanging some servers
| From: | Julio Nobrega Trabalhando | Date: | Tue, 06 Nov 2001 17:47:50 +0000 |
| Subject: | Function hanging some servers | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-73625@lists.php.net to get a copy of this message | ||
Hi All!
Here comes another doubt. I managed to make my current scripts without
this function. So, this is not a 'problem' that needs a solution. Instead,
just a small doubt.
This code happens to run on my dev computer fine. Win2k, Athlon 1.3, 128
RAM, Apache 1.3.20, PHP 4.0.6. But on two other machines, one is a Linux
with same PHP and Apache versions (don't know the 'speed') and the other is
a Win2k with IIS 5.0 (same PHP version, don't know the machine 'speed'),
this small functions 'hangs' the processing of the script. It just don't
load the page, until a maximum execution time happens.
Why is this function so evil on other's people computer? :-D
MS: usage:
$data = '2001-11-06 15:45:35';
$periodo = 'Data';
$var =& data_brasil($data,$periodo);
echo $var;
// expected output: 06-11-2001
// What happens? Lock others people servers...
function &data_brasil($data, $periodo)
{
if ($periodo == 'Ano') {
$comeco = 0;
} elseif ($periodo == 'Mês') {
$comeco = 5;
} elseif ($periodo == 'Dia') {
$comeco = 8;
} elseif ($periodo == 'Hora') {
$comeco = 11;
} elseif ($periodo == 'Minuto') {
$comeco = 14;
} elseif ($periodo == 'Segundo') {
$comeco = 17;
} elseif ($periodo == 'Horário') {
$comeco = 11;
}
$final = 2;
if ($periodo == 'Ano') {
$final = $final * 2;
} elseif ($periodo == 'Horário') {
$final = $final * 4;
}
$brasil_data = substr($data,$comeco,$final);
if ($periodo == 'Data') {
$data = substr($data,0,10);
$data = explode('-',$data);
$data = array_reverse($data);
$brasil_data = implode('-',$data);
return ($brasil_data);
} else {
return ($brasil_data);
}
}
--
Julio Nobrega
A hora está chegando:
http://toca.sourceforge.net