使用未定义的常数 - 假设''在PHP中

时间:2014-08-13 12:24:03

标签: php

    <?php
         $f=$_POST['rdate'];
          echo $f."</br>";
           $from=$f.'-01 00:00:00';
           $dayyy=explode("-",$f);
           //print_r($dayyy);
           $year=$dayyy[0];
           echo $year."</br>";
           $mm=$dayyy[1];   
            echo $mm."</br>";
        $mons = array("01" => "Janauary", "02" => "February", "03"=>"March", "04"=>"April", "05"=>"May", "06"=>"June", "07"=>"July", "08"=>"August", "09"=>"September", "10"=>"October", "11"=>"November", "12"=>"December");
        print_r($mons);
        /*foreach($mons as $mm)
        {
          echo $mm; 
        }*/
        $month_name = $mons[$mm];
        echo "</br>".$month_name;
      $days=cal_days_in_month(CAL_GREGORIAN, $mm, $year);
        $dayss= $days-1;
        echo $dayss."</br>";
        $dayys=' + '.$dayss.' days' ;
        $var=$from.$dayys;
        //echo $var."</br>";
        echo "Last".date('Y-m-d 23:59:59',strtotime($var));​

        ?>

我正在使用未定义的常量 - 在上面的代码中假设错误。 我想这是因为没有破坏spce而得到这个问题,但不知道我离开了哪里? 请帮助!!


2 个答案:

答案 0 :(得分:4)

你的

上有某种奇怪的角色
echo "Last".date('Y-m-d 23:59:59',strtotime($var));

线 记事本++无法看到它但是当我试图箭头抛出它时,它经历了两次。

无论如何,删除该行并复制并粘贴此

echo "Last".date('Y-m-d 23:59:59',strtotime($var));

答案 1 :(得分:0)

检查您正在使用的常量是否定义.. 如果不定义

代码将是

<?php 

  if (!defined('CAL_GREGORIAN')) 
    define('CAL_GREGORIAN', 0); 

   $f=$_POST['rdate'];
          echo $f."</br>";
           $from=$f.'-01 00:00:00';
           $dayyy=explode("-",$f);
           //print_r($dayyy);
           $year=$dayyy[0];
           echo $year."</br>";
           $mm=$dayyy[1];   
            echo $mm."</br>";
        $mons = array("01" => "Janauary", "02" => "February", "03"=>"March", "04"=>"April", "05"=>"May", "06"=>"June", "07"=>"July", "08"=>"August", "09"=>"September", "10"=>"October", "11"=>"November", "12"=>"December");
        print_r($mons);
        /*foreach($mons as $mm)
        {
          echo $mm; 
        }*/
        $month_name = $mons[$mm];
        echo "</br>".$month_name;
      $days=cal_days_in_month(CAL_GREGORIAN, $mm, $year);
        $dayss= $days-1;
        echo $dayss."</br>";
        $dayys=' + '.$dayss.' days' ;
        $var=$from.$dayys;
        //echo $var."</br>";
        echo "Last".date('Y-m-d 23:59:59',strtotime($var));