Php... 01 greater than 1 ???

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
First, sorry for telling you so little with this issue and leaving it
for so long without much care from me...

Below you can find the script that made feel confused (I am an early
Php beginner but I have to stop as for professional needs I need to
concentrate my free time on learning VBA...) :

Test it with 01 as I can't test it on my current configuration(see
below why).





//lancer recherche         $_POST['submit']     dans fichier aide PHP

if (!$_POST['submit'])



<form action="<?=$_SERVER['PHP_SELF']?>" method="post">

Saisissez un nombre : <input name="nombre" size="2">

<input type="submit" name="submit" value="Valider">






$nombre = $_POST['nombre'];

if ($nombre < 0)

{echo 'Vous avez saissi un nombre -';

elseif ($nombre > 0)

{echo 'Vous avez saissi +';


{echo 'Vous avez saissi un nombre neutre';






As I changed computer, I had to reinstall php, apache and I wanted to
test this script again but I had this message:

You don't have permission to access /arch/< on this server.

The other script I run all are working (with forms...) under XP.

It's no big issue for me right now as it's confusing learning 2
languages at the same time... so I am concentrating on vba and leaving
Php for later...

Re: Php... 01 greater than 1 ???

Quoted text here. Click to load it

Maybe you've installed a newer PHP-Version or you've forgott to
configure PHP. I see the usage of short tags inside your script (<form
action="<?=$_SERVER['PHP_SELF']?>" method="post">).

If handling of short tags are deactivated (this is the default
setting), PHP will not parse the code <?=$_SERVER['PHP_SELF']?>.
Instead of that, the HTML output will contain it as string.

You can change this behaviour by setting "short_open_tag = Off" in the
php.ini file, which should be present either normally in C:\WINDOWS\
or inside the PHP installation directory.

But the better alternative is not to use short tags syntax and to
change your script as follows:
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">


Re: Php... 01 greater than 1 ???


For the first issue, I came to understand from a similar post I made
earlier that the reason why 01 is greater than 1 is because of :

$nombre = $_POST['nombre']

the memory address is the one that is being tested and 01 is greater
than 1 because 01 is 2 characters long... is it the explanation?

About the second issue, I remember having some php or apache
configuration issues as I did some installation on different computer
running windows xp home or pro.... and for some the same configuration
would work and for others it wouldn't so at some point I had to
install  the xamp all in one software that make things go smoothly.

For now, I have set the short tag "off" to "on" in php.ini and I have
also changed the php script to echo $_SERVER but with the first change
(and with no change in code), it still gives me a forbidden message,
and for the second change (leaving php.ini "on" or "off"), it does
nothing when I click submit like, I get the same blank input box as I
got before entering a number...

It might be something either very little or something a very early
irregular php learner like me can't get and so obvious to any one else
php litterate....

One last thing, is it okay for someone to learn vba thinking that
after getting vba skills (after a year or two giving it about 4 hours
a week), it will be convenient to go on learning php? However so far
with Vba, it looks closer to java than php. I would like to know an
open-source language and apart vba, learning those language would just
be a hobby. But there are so many language and the web technologies
are moving quite fast ...see ajax... so someone without any IT
academic like me can feel quite confused.

Thanks again

Re: Php... 01 greater than 1 ???

wbrowse wrote:
Quoted text here. Click to load it

well, php dont support type definitions. That means variables will get  
evaluated based on the operation. I had similar problems with a switch  
statement comparing a value with leading zero with a number. For me it  
looked like the value with leading zero "01" got interpreted as string  
and compared with the number 1 the result is false.

That should help you out:
$nombre = (int) $_POST['nombre'];

More about this topic:

Site Timeline