Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

syntax perl vs php

Status
Not open for further replies.

edpatterson

IS-IT--Management
Feb 24, 2005
186
No, I am not looking to start a holy war, I am looking for expalinations in converting perl syntax to php.

I tried this code:[tt]
<?php
$var1 = 8;
$var2 = 1;
print "$var1 < $var2 -- ".$var1 < $var2."<br />";
?>[/tt]
and received a blank page. Changing it to:
<?php[tt]
$var1 = 8;
$var2 = 1;
print "$var1 < $var2 -- ";
print $var1 < $var2;
?>[/tt]
returns
8 < 1 --
I was expecting:
8 < 1 -- True (or 1 or any non zero number)

I thought the . was the concatenation operator and I assumed the boolean test would return it's value.

Thanks for any pointers.
Ed
 
Try putting this:

$var1 < $var2

inside parentheses:

($var1 < $var2)

Lee
 
For some reason the false condition kills the string.
Giving you nothing in your first example.

PHP returns an "" empty string for false and 1 for true so you could do this:

Code:
echo "$var1 > $var2 -- ".strlen($var1 > $var);

Good Place to "Learn More">>
W3 Schools
 
Thanks, I just noticed that my example returned false and not true. I guess I should have my coffee before coding.

Thanks too for the link 'Good Place to "Learn More">>'. A very nice site. I'll have to see if they sell coffee cups. I'll get one to put next to my Tek-Tips cup. A very nice cup by the way.

Ed
 
You're welcome.

Yes, I agree it should always be coffee then code.
And some mornings it should be coffee, coffee then code.

Thanks,
Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top