You are here: Re: Design Comments and positioning problems « HTML « IT news, forums, messages
Re: Design Comments and positioning problems

Posted by Els on 09/29/05 02:11

Toby Inkster wrote:

> Els wrote:
>
>> My knowledge of PHP doesn't extend beyond the use of an include or a
>> simple if/else statement yet. I know that 'int' rounds a number to an
>> integer, but that's about as much as I can see in the above snippet.
>
> Not quite. It's a "type cast". That is, it forces the string value "2" to
> an integer value 2. PHP is a "weakly typed" language, which means that
> most of the time, PHP will do all the casting you need for you. But it's
> usually a good idea to do it explicitly, to prevent any nasty surprises.
>
> <?php
>
> if ("2"=="2.0")
> {
> print "This will never happen.\n";
> }
>
> if ( (int)"2" == (int)"2.0" )
> {
> print "This will happen!\n";
> }
>
> ?>
>
> Of course, if you have a fractional number and do a type cast to an
> integer:
>
> $x = (int)4.25;
>
> it has the same effect as rounding the number -- but this is merely a
> side-effect: the main operation has been casting a floating-point number
> to an integer.
>
>> Just a guess: somewhere in the week the value of 'w' rounds down or up
>> to the wrong integer to be accurate for the day?
>
> http://www.php.net/date
>
> date("w") returns the current day of the week as a numeric string. If
> today is a Monday, then it returns "1"; if today is Tuesday, it returns
> "2"; etc.
>
> If it's Sunday, it returns "0": thus "if ($day)" evaluates to "if (0)";
> which is always false: so the paragraph does not get printed at all.

Got it :-)

You really should be a teacher, you know that?

--
Els http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -

 

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

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