I've got PHP back today.

Source: Internet
Author: User

Made an instance of PHP

is a perpetual calendar of PHP

Call Date () and use of loop structure

It's a simple interface, but the basic function is this.

Don't say much nonsense on the code

PHP$year=Empty($_get[' Y '])?Date("Y"):$_get[' Y ']; $mon=Empty($_get[' m '])?Date("M"):$_get[' m ']; Echo"$yearYears$mon} Month ; ?> <table width= "@" border= "1" > <tr> <th> Sunday </th>                <th> Monday </th> <th> Tuesday </th> <th> Wednesday </th>            <th> Thursday </th> <th> Friday </th> <th> Saturday </th> </tr> <?PHP$day=Date("T",Mktime(0,0,0,$mon, 1,$year)); $w=Date("W",Mktime(0,0,0,$mon, 1,$year)); $XQ= 1;  while($XQ<=$day) {                     Echo"<tr>";  for($i= 0;$i<= 6;$i++) {                     if($XQ>$day|| ($w>$i&&$XQ==1)) {                           Echo"<td>&nbsp;</td>"; }Else{                          Echo"<td>{$XQ}</td> "; $XQ++; }                    }                     Echo"<tr>"; }                Echo"</table>; $nyear=$year;//next year                $pyear=$year;//last year                $nmon=$mon+1; $pmon=$mon-1; if($nmon>12) {                    $nyear=$year+1; $nmon=1; }                if($pmon<1) {                    $pyear=$year-1; $pmon=12; }                Echo"<a href= ' date.php?y={$pyear}&m={$pmon} ' > Last month </a> '; Echo"&nbsp;&nbsp;&nbsp;&nbsp;"; Echo"<a href= ' date.php?y={$nyear}&m={$nmon} ' > Next month </a> '; ?> </center></body>

Above the.

Empty (xx1)? xx2:xx3;

is a ternary operator

Presumably, it means

If the xx1 is a value then execute xx2, if xx1 is empty then execute xx3;

And the use of empty.

Introduction to Date ()

The following is a link to the English version of the PHP manual more see the Harvest

Link: Https://pan.baidu.com/s/1bPTK11wr79fDD3KcKm9q_Q Password: xfid

I've got PHP back today.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.