搜索
首页后端开发php教程php 日历类 日历控件

";
  • }
  • public function getEndTR() {
  • $this->retunrhtml .= "
  • ";
  • }
  • protected function getDay() {
  • return $this->day;
  • }
  • protected function getMonth() {
  • return $this->month;
  • }
  • protected function getYear() {
  • return $this->year;
  • }
  • protected function isWeekend() {
  • return $this->weekend;
  • }
  • protected function isCurrent() {
  • return $this->currentdate;
  • }
  • public function getTDHref() {
  • return $this->getDay();
  • }
  • public function getTD() {
  • $class = '';
  • $td = "td";
  • if ($this->isCurrent()) {
  • $class = 'today';
  • }
  • $this->retunrhtml .= "" . $this->getTDHref() . "$td>";
  • }
  • public function getTDWeekend() {
  • $class = '';
  • $td = "td";
  • if ($this->isCurrent()) {
  • $class = 'today';
  • }
  • $this->retunrhtml .= "" . $this->getTDHref() . "$td>";
  • }
  • protected function makeCodeMonth($year, $month) {
  • $this->makeWeeks($year, $month);
  • $this->getCalendarHeader();
  • for ($i = 0; $i week); $i++) {
  • $this->getBeginTR();
  • for ($j = 0; $j
  • if (!empty($this->week[$i][$j])) {
  • $this->day = $this->week[$i][$j];
  • $this->currentdate = 0;
  • if ($this->year == date('Y') && $this->month == date('m') && $this->day == date('j')) {
  • $this->currentdate = 1;
  • }
  • if ($j == 5 || $j == 6) {
  • $this->weekend = 1;
  • $this->getTDWeekend();
  • }
  • else {
  • $this->weekend = 0;
  • $this->getTD();
  • }
  • }
  • else {
  • $this->retunrhtml .= "
  • ";
  • }
  • }
  • $this->getEndTR();
  • }
  • $this->getCalendarFooter();
  • }
  • public function getCodeMonth() {
  • $this->makeCodeMonth($this->year, $this->month);
  • return $this->retunrhtml;
  • }
  • public function showCodeMonth() {
  • echo $this->getCodeMonth();
  • }
  • }
  • class TechCalendarForm extends CalendarForm {
  • public function getTDHref() {
  • if ($this->isWeekend()) {
  • $font = "";
  • }
  • else {
  • $font = "";
  • }
  • return "" . $font . parent::getDay() . "
  • ";
  • }
  • }
  • 复制代码
    1. class CalendarForm {
    2. protected $year;
    3. protected $month;
    4. protected $day;
    5. protected $weekend;
    6. protected $currentdate;
    7. protected $dayofmonth;
    8. protected $day_count;
    9. protected $num;
    10. protected $week = array();
    11. protected $retunrhtml = "";
    12. function __construct($year, $month) {
    13. $this->makeWeeks($year, $month);
    14. }
    15. public function setYearMonth($year, $month) {
    16. $this->year = $year;
    17. $this->month = $month;
    18. }
    19. private function resetDayCount() {
    20. $this->day_count = 1;
    21. }
    22. private function setFirstWeek() {
    23. $this->num = 0;
    24. }
    25. public function getDayOfMonth($year, $month) {
    26. $this->resetDayCount();
    27. return date('t', mktime(0, 0, 0, $month, $this->day_count, $year));
    28. }
    29. private function setDayOfMonth($year, $month) {
    30. $this->dayofmonth = $this->getDayOfMonth($year, $month);
    31. }
    32. private function getDayOfWeek() {
    33. return date('w', mktime(0, 0, 0, $this->month, $this->day_count, $this->year));
    34. }
    35. public function getNextMonth() {
    36. return date('m', mktime(0, 0, 0, $this->month, 28, $this->year) + 432000);
    37. }
    38. public function getNextYear() {
    39. return date('Y', mktime(0, 0, 0, $this->month, 28, $this->year) + 432000);
    40. }
    41. public function getPrevMonth() {
    42. return date('m', mktime(0, 0, 0, $this->month, 1, $this->year) - 432000);
    43. }
    44. public function getPrevYear() {
    45. return date('Y', mktime(0, 0, 0, $this->month, 1, $this->year) - 432000);
    46. }
    47. private function makeWeeks($year, $month) {
    48. $this->setYearMonth($year, $month);
    49. $this->setDayOfMonth($this->year, $this->month);
    50. $this->setFirstWeek();
    51. $this->num = 0;
    52. for ($i = 0; $i $dayofweek = $this->getDayOfWeek();
    53. $dayofweek = $dayofweek - 1;
    54. if ($dayofweek == -1) {
    55. $dayofweek = 6;
    56. }
    57. if ($dayofweek == $i) {
    58. $this->week[$this->num][$i] = $this->day_count;
    59. $this->day_count++;
    60. }
    61. else {
    62. $this->week[$this->num][$i] = "";
    63. }
    64. }
    65. while (TRUE) {
    66. $this->num++;
    67. for ($i = 0; $i $this->week[$this->num][$i] = $this->day_count;
    68. $this->day_count++;
    69. if ($this->day_count > $this->dayofmonth) {
    70. break;
    71. }
    72. }
    73. if ($this->day_count > $this->dayofmonth) {
    74. break;
    75. }
    76. }
    77. }
    78. public function getCalendarHeader() {
    79. $this->retunrhtml =
    80. "" .
    81. "
    82. " .
    83. "
    84. " .
    85. "
    86. " .
    87. "
    88. " .
    89. "
    90. " .
    91. "
    92. " .
    93. "
    94. " .
    95. "
    96. " .
    97. "
    98. " .
    99. "
    100. " .
    101. "
    102. ";
    103. }
    104. public function getCalendarFooter() {
    105. $this->retunrhtml .= "
    106. " . $this->month . "/" . $this->year . "
      Monday Tuesday Wednesday Thursday Friday Saturday Sunday
      ";
    107. }
    108. public function getBeginTR() {
    109. $this->retunrhtml .= "
    php


    声明
    本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
    高流量网站的PHP性能调整高流量网站的PHP性能调整May 14, 2025 am 12:13 AM

    TheSecretTokeEpingAphp-PowerEdwebSiterUnningSmoothlyShyunderHeavyLoadInVolvOLVOLVOLDEVERSALKEYSTRATICES:1)emplactopCodeCachingWithOpcachingWithOpCacheToreCescriptexecution Time,2)使用atabasequercachingCachingCachingWithRedataBasEndataBaseLeSendataBaseLoad,3)

    PHP中的依赖注入:初学者的代码示例PHP中的依赖注入:初学者的代码示例May 14, 2025 am 12:08 AM

    你应该关心DependencyInjection(DI),因为它能让你的代码更清晰、更易维护。1)DI通过解耦类,使其更模块化,2)提高了测试的便捷性和代码的灵活性,3)使用DI容器可以管理复杂的依赖关系,但要注意性能影响和循环依赖问题,4)最佳实践是依赖于抽象接口,实现松散耦合。

    PHP性能:是否可以优化应用程序?PHP性能:是否可以优化应用程序?May 14, 2025 am 12:04 AM

    是的,优化papplicationispossibleandessential.1)empartcachingingcachingusedapcutorediucedsatabaseload.2)优化的atabaseswithexing,高效Quereteries,and ConconnectionPooling.3)EnhanceCodeWithBuilt-unctions,避免使用,避免使用ingglobalalairaiables,并避免使用

    PHP性能优化:最终指南PHP性能优化:最终指南May 14, 2025 am 12:02 AM

    theKeyStrategiestosiminificallyBoostphpapplicationPermenCeare:1)useOpCodeCachingLikeLikeLikeLikeLikeCacheToreDuceExecutiontime,2)优化AtabaseInteractionswithPreparedStateTemtStatementStatementSandProperIndexing,3)配置

    PHP依赖注入容器:快速启动PHP依赖注入容器:快速启动May 13, 2025 am 12:11 AM

    aphpdepentioncontiveContainerIsatoolThatManagesClassDeptions,增强codemodocultion,可验证性和Maintainability.itactsasaceCentralHubForeatingingIndections,因此reducingTightCightTightCoupOulplingIndeSingantInting。

    PHP中的依赖注入与服务定位器PHP中的依赖注入与服务定位器May 13, 2025 am 12:10 AM

    选择DependencyInjection(DI)用于大型应用,ServiceLocator适合小型项目或原型。1)DI通过构造函数注入依赖,提高代码的测试性和模块化。2)ServiceLocator通过中心注册获取服务,方便但可能导致代码耦合度增加。

    PHP性能优化策略。PHP性能优化策略。May 13, 2025 am 12:06 AM

    phpapplicationscanbeoptimizedForsPeedAndeffificeby:1)启用cacheInphp.ini,2)使用preparedStatatementSwithPdoforDatabasequesies,3)3)替换loopswitharray_filtaray_filteraray_maparray_mapfordataprocrocessing,4)conformentnginxasaseproxy,5)

    PHP电子邮件验证:确保正确发送电子邮件PHP电子邮件验证:确保正确发送电子邮件May 13, 2025 am 12:06 AM

    phpemailvalidation invoLvesthreesteps:1)格式化进行regulareXpressecthemailFormat; 2)dnsvalidationtoshethedomainhasavalidmxrecord; 3)

    See all articles

    热AI工具

    Undresser.AI Undress

    Undresser.AI Undress

    人工智能驱动的应用程序,用于创建逼真的裸体照片

    AI Clothes Remover

    AI Clothes Remover

    用于从照片中去除衣服的在线人工智能工具。

    Undress AI Tool

    Undress AI Tool

    免费脱衣服图片

    Clothoff.io

    Clothoff.io

    AI脱衣机

    Video Face Swap

    Video Face Swap

    使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

    热门文章

    热工具

    SublimeText3 Linux新版

    SublimeText3 Linux新版

    SublimeText3 Linux最新版

    SublimeText3汉化版

    SublimeText3汉化版

    中文版,非常好用

    Dreamweaver CS6

    Dreamweaver CS6

    视觉化网页开发工具

    VSCode Windows 64位 下载

    VSCode Windows 64位 下载

    微软推出的免费、功能强大的一款IDE编辑器

    SublimeText3 Mac版

    SublimeText3 Mac版

    神级代码编辑软件(SublimeText3)