You are here: Re: A Problem in understanding PHP code « PHP Programming Language « IT news, forums, messages
Re: A Problem in understanding PHP code

Posted by Jerry Stuckle on 06/15/05 14:54

Bsedigh_79@yahoo.com wrote:
> hi everybody.
>
> I'am a C# programmer and for one of my applications i searched web for
> a piece of code and finally i found it but in PHP.
> it was easy to understand the logic but i still have a problem with it.
> There is single line of code that i can't understand.Would u please
> help me and explain what is going on?
>
> Code :
> 1)
> for ($i = 0; $g_day_no >= $g_days_in_month[$i] + ($i == 1 &&
> $leap); $i++)
> $g_day_no -= $g_days_in_month[$i] + ($i == 1 && $leap);
>
> $g_day_no >= $g_days_in_month[$i] + ($i == 1 && $leap) :-/
>
> 2)
> what is div statement?
> There is a line of code like this:
>
> $gy += 4*div($g_day_no, 1461);
>
> what is div for?
> i searched in PHP functions but i did not find anything.
>
> Thanks for ur appreciates.
> Behzad
>

Behzad,

The code probably isn't commented as well as it could. However, my bust
guess:

1). $i is probably the month number (0-11 instead of 1-12). $leap would
be true or false, depending on if it's a leap year. If it is a leap
year ($leap == true) and February ($i == 1), then add 1 to the number of
days in the month ($g_days_in_month[$i]). It works because a "true"
value is converted to an int with the value of "1". False converted to
an int has the value "0".

2). I haven't seen it - I suspect's a user-defined function. I have no
idea what it does, other than there are 1461 days every 4 years (with 3
exceptions every 400 years...). So perhaps it returns an integer value
of the results of the division. This would tell how many 4-year blocks
there are, Multiply by 4 to get the number of years.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

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

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