You are here: Re: Whats wrong with this code? « PHP Programming Language « IT news, forums, messages
Re: Whats wrong with this code?

Posted by Pedro Graca on 10/05/06 21:17

Garry Jones wrote:
> First - Exerpt from a form.
>
> <select name="dtctxsz1" class="vtredstar" id="dtctxsz1">
> <option value="0" selected>Ej vald</option>
> <option value="xs">XS</option>
[...]
> </select>
>
> Processed by.....
>
> $antroj = 0;
> $dtctxsz1 = $_POST["dtctxsz1"];
> if($dtctxsz1 == 0){
> print $dtctxsz1;
> $antroj = $antroj + 1;
> }

if ('fortytwo' == 0) echo 'Douglas Adams had it wrong!';

You should have a look at the Type Juggling manual page:
http://www.php.net/manual/en/language.types.type-juggling.php


<?php
header('Content-Type: text/plain');
error_reporting(E_ALL);
ini_set('display_errors', '1');

$x1 = '0';
$x2 = 'xs';
$x3 = 0;

$tests = array();
$tests[] = 'return $x1 == $x2;';
$tests[] = 'return $x1 === $x2;';
$tests[] = 'return $x1 == $x3;';
$tests[] = 'return $x1 === $x3;';
$tests[] = 'return $x2 == $x3;';
$tests[] = 'return $x2 === $x3;';
$tests[] = 'return $x1 == 0;';
$tests[] = 'return $x1 === 0;';
$tests[] = 'return $x1 == \'0\';';
$tests[] = 'return $x1 === \'0\';';
$tests[] = 'return $x2 == 0;';
$tests[] = 'return $x2 === 0;';
$tests[] = 'return $x2 == \'0\';';
$tests[] = 'return $x2 === \'0\';';
$tests[] = 'return $x3 == 0;';
$tests[] = 'return $x3 === 0;';
$tests[] = 'return $x3 == \'0\';';
$tests[] = 'return $x3 === \'0\';';

echo '$x1 = \'0\';
$x2 = \'xs\';
$x3 = 0;

';
$n = 0;
foreach ($tests as $v) {
echo $v, "\treturns ", (eval($v)) ? ('true') : ('false'), "\n";
}
?>

--
File not found: (R)esume, (R)etry, (R)erun, (R)eboot

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация