Hi. I can't believe it's over 10 years and I still don't know nearly as much about this langhuage as I should. Problem is I only use the basics and only care that my script works. Anyway, it's been over 13 years since I was here last. Wow.
So. I'm modifying a calendar script that some guy put up someplace to show people how to make a calendar script. Anyone interested in it can go here: http://www.startutorial.com/articles/vi ... dar-in-php.
I'm going to use it on a couple of web sites for events. I just have a couple of questions maybe someone can help with. Probably simple for php programmers but I'm still in novice class and probably always will be.
What does the percent sign, number and question mark (%7?) mean at the end of a variable. For instance, $cellNumber%7?==1 and $cellNumber%7?==0 .
It's used in line number 129 on script at website below. Thanks.
http://www.startutorial.com/articles/vi ... dar-in-php
what does % mean after a variable
Moderator: General Moderators
what does % mean after a variable
Last edited by bayridge on Fri Mar 11, 2016 3:43 pm, edited 1 time in total.
Re: what does % mena after a variable
Code: Select all
return '<li id="li-'.$this->currentDate.'" class="'.($cellNumber%7==1?' start ':($cellNumber%7==0?' end ':' ')).($cellContent==null?'mask':'').'">'.$cellContent.'</li>';- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: what does % mena after a variable
Also look at the ternary operator:
http://php.net/manual/en/language.opera ... arison.php (halfway down the page)
Note - the parens in that line are so the concatenation works on the values chosen by the ternary operations.
http://php.net/manual/en/language.opera ... arison.php (halfway down the page)
Note - the parens in that line are so the concatenation works on the values chosen by the ternary operations.
(#10850)
Re: what does % mena after a variable
Nested ternaries are a bit of a mess to read, but it's basically setting calendar width by checking if you're at the start/end of a row by dividing by zero.
Re: what does % mean after a variable
Okay, I'm even worse at math. This guy was writing an article on how to write a basic calendar. I got it working and made a few mods to it and still want to do some more, but it's way beyond my level of php. I was a mainframe programmer using COBOL and CICS for 25 years and retired and started doing web pages with MySQL and php that I picked up myself. I just learned enough to do simple web pages. Anyway, I think this tutorial this guy wrote is way too hard for a beginner. I'll probably just use the logic he used and start from scratch and do my own. I don't use the stuff he is like public and private and $this-> ternaries and so on, just the basic beginner stuff.
So thanks for the help and I'm glad I found this board again. I'll probably be back soon with more questions. Do you guys have a donate page or something? I don't like to keep taking and not be able to contribute cause I don't know enough.
So thanks for the help and I'm glad I found this board again. I'll probably be back soon with more questions. Do you guys have a donate page or something? I don't like to keep taking and not be able to contribute cause I don't know enough.