Jump to content

Recommended Posts

I'm a little new to this and inherited some code.

 

I see this line of code but I don't know what it's suppose to do.

 

if(date(s)%2 == 0)

 

Can someone explain it to me?

I'm thinking the s should be in quotes and I don't know what the %2 does

 

Any guidance will be appreciated

Link to comment
https://forums.phpfreaks.com/topic/256119-what-does-this-date-code-do/
Share on other sites

the 's' should be in quotes, yes.

 

% is the modulous operator

 

This line basically says "only execute the following code on even-numbered seconds."

 

I don't know why they'd want that.  I also don't know why they used 's' instead of the more correct 'U'

Thank you very much, the code displays one image if even then another if odd. what I can't understand is why it worked as is before I inherited it, where now I get an error on the if(date(s) say it wants to know what s is.  That's why I thought it needed the quotes.

It should have always generated a warning, it's poorly written.  You may have enabled errors or upgraded your server or whatever to generate the error.  All strings need to be quoted, or you'll get an undefined constant error.

Maniac Dan,

 

Thank you very much I've been pulling my hair out trying to figure out why this code ran before but wouldn't run once we transfered it over to our server.  Evidently the server that it resided on before hasn't been updated.  There's lots of work to do, errors pop up everywhere.  I might just rewrite the whole thing.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.