473,242 Members | 1,435 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,242 software developers and data experts.

A Problem in understanding PHP code

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

Jul 17 '05 #1
7 1514

<Bs********@yahoo.com> a écrit dans le message de news:
11**********************@g43g2000cwa.googlegroups. com...
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.

Hi,
Div is Probably a user function...
Because in Php, there's nothing like this..

Bye,
Jul 17 '05 #2
On Wed, 15 Jun 2005 12:11:53 +0200, <Bs********@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++)
its simple for loop...
for //starting loop
($i = 0; //initiating count variable
($g_day_no) >= ( $g_days_in_month[$i] + ($i == 1 &&> $leap)); //just
condition I addet () so maybe you se better
can be more explained firts variable in condition $g_day_no
if $g_day_no bigger or equal to ( $g_days_in_month[$i] + ($i == 1 &&>
$leap))

second variable in condition ( $g_days_in_month[$i] + ($i == 1 &&>
$leap)), this one depends on i with will drow until the enequality returns
true
$i++) //grow by 1
I'am guesing you forgot brakets? {}
n that case the above code ll by executet while enequality is false
$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 think that is some local funktion, you should check for that

i searched in PHP functions but i did not find anything.
Thanks for ur appreciates.
Behzad


--

Thanx in advance
________________________
BTW. I know my english is not best in the word, so please stop bugging me
about my spelling. And yes Iam sorry you don't understand what I mean, but
there is no point to yell at me. Have a nice day.

Jul 17 '05 #3
Bs********@yahoo.com wrote:
$g_day_no >= $g_days_in_month[$i] + ($i == 1 && $leap) :-/


Some implicit casting in action:
i+true ==i+1
i+false==i

Jul 17 '05 #4
Bs********@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.
js*******@attglobal.net
==================
Jul 17 '05 #5
I noticed that Message-ID: <vd********************@comcast.com> from
Jerry Stuckle contained the following:

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.


Am I alone in thinking that this is possibly trying to reinvent existing
PHP date manipulation functions?

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #6
Geoff Berrow wrote:
I noticed that Message-ID: <vd********************@comcast.com> from
Jerry Stuckle contained the following:

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.

Am I alone in thinking that this is possibly trying to reinvent existing
PHP date manipulation functions?


Hi, Geoff,

No, you're not alone :-)

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 17 '05 #7
hi everybody

thanks for your repleis.
To see compelet code follow the this problem:

http://www.iranphp.net/modules/secti...ticle&artid=19

Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mike | last post by:
Hey guys, need some help understanding some things that maybe someone can explain or clarify it a little better then a text book. Here is my understanding so far: Class - basically a shell for...
9
by: ShadowOfTheBeast | last post by:
Hi, I have got a major headache understanding streamReader and streamWriter relationship. I know how to use the streamreader and streamwriter independently. but how do you write out using the...
26
by: Bail | last post by:
I will have a exam on the oncoming friday, my professor told us that it will base upon this program. i am having troubles understanding this program, for example what if i want to add all the...
18
by: Simon | last post by:
Hi, I understand what one the differences between std::vector, std::deque and std::list is, the std::vector can have data inserted/deleted at the end. The std::deque can have data...
1
by: Anonieko | last post by:
Understanding and Using Exceptions (this is a really long post...only read it if you (a) don't know what try/catch is OR (b) actually write catch(Exception ex) or catch{ }) The first thing I...
4
by: joelagnel | last post by:
I'm new to .NET and have a basic understanding of operating systems. I can also do some magic in Csharp, but I lack an understanding of what's going on under the hood, with respect to how windows...
10
by: sasquatch | last post by:
X-No-Archive: Are there any good books that provide tips about how to understand and "play with" large C++ programs? It seems like a very important skill, and yet its hardly taught in the...
8
by: boki_pfc | last post by:
Hi Everybody, I am looking for an advice on following: I have that "pleasure" of reading C++ codes that have been written by person(s) that have not attended the same C++ classes that I did or...
2
by: subramanian100in | last post by:
Is my following understanding correct ? Data abstraction means providing the interface - that is, the set of functions that can be called by the user of a class. Information hiding means...
3
by: PVACC | last post by:
I have a line of code thus: w3('<input type=radio name=rad onclick="parent.mySub('+i+')">'); The function w3() writes the code in an iframe. I need to set a variable "start" to the value "1"...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.