我在更改主机后出错:在我的Wordpress网站上。
严格标准:日期():依赖系统是不安全的 时区设置。您必需使用date.timezone设置 或者date_default_timezone_set()函数。如果您使用过任何一个 那些方法,你最有可能仍然得到这个警告 拼写错误的时区标识符。我们选择了欧洲/柏林'对于 ' CET / 1.0 /无DST'相反 /homepages/42/d545555785/htdocs/lifetips.ro/baby-gender-predictor.php 在第69行
严格标准:日期():依赖系统是不安全的 时区设置。您必需使用date.timezone设置 或者date_default_timezone_set()函数。如果您使用过任何一个 那些方法,你最有可能仍然得到这个警告 拼写错误的时区标识符。我们选择了欧洲/柏林'对于 ' CET / 1.0 /无DST'相反 /homepages/..../htdocs/lifetips.ro/baby-gender-predictor.php上线 76
严格标准:strtotime():依赖系统是不安全的 时区设置。您必需使用date.timezone设置 或者date_default_timezone_set()函数。如果您使用过任何一个 那些方法,你最有可能仍然得到这个警告 拼写错误的时区标识符。我们选择了欧洲/柏林'对于 ' CET / 1.0 /无DST'相反 /homepages/..../htdocs/lifetips.ro/baby-gender-predictor.php上线 82
严格标准:strtotime():依赖系统是不安全的 时区设置。您必需使用date.timezone设置 或者date_default_timezone_set()函数。如果您使用过任何一个 那些方法,你最有可能仍然得到这个警告 拼写错误的时区标识符。我们选择了欧洲/柏林'对于 ' CET / 1.0 /无DST'相反 /homepages/..../htdocs/lifetips.ro/baby-gender-predictor.php上线 82
生成于此ca. 200行代码:
<?php
/* This predictor is your for free by EverydayVBabies.com. You have no obligations for anything - you can modify, redistribute, sell it or whatever you want to do.
We will appreciate if you don't remove the link at the bottom, but that's not required. */
/* Feel free to modify the CSS and the texts below. - no problem at all. Just don't touch the PHP code or the specual codes which are surrounded with %% unless you know what you are doing. */
error_reporting(E_ALL&(~E_NOTICE));
@session_start();
?>
<style type="text/css">
.calculator_div
{
font-family:verdana, arial, sans-serif;
border:2pt solid #FF44FF;
padding:25px;
width:250px;
margin:auto;
}
label
{
display:block;
float:left;
width:150px;
}
</style>
<?php
// present the calculator table as multi-dimentional PHP array
$table=array(
"18"=>array("",'f','m','f','m','m','m','m','m','m','m','m','m'),
"19"=>array("",'m','f','m','f','f','m','m','m','m','m','f','f'),
"20"=>array("",'f','m','f','m','m','m','m','m','m','f','m','m'),
"21"=>array("",'m','f','f','f','f','f','f','f','f','f','f','f'),
"22"=>array("",'f','m','m','f','m','f','f','m','f','f','f','f'),
"23"=>array("",'m','m','f','m','m','f','m','f','m','m','m','f'),
"24"=>array("",'m','f','m','m','f','m','m','f','f','f','f','f'),
"25"=>array("",'f','m','m','f','f','m','f','m','m','m','m','m'),
"26"=>array("",'m','f','m','f','f','m','f','m','f','f','f','f'),
"27"=>array("",'f','m','f','m','f','f','m','m','m','m','f','m'),
"28"=>array("",'m','f','m','f','f','f','m','m','m','m','f','f'),
"29"=>array("",'f','m','f','f','m','m','m','m','m','f','f','f'),
"30"=>array("",'m','f','f','f','f','f','f','f','f','f','m','m'),
"31"=>array("",'m','f','m','f','f','f','f','f','f','f','f','m'),
"32"=>array("",'m','f','m','f','f','f','f','f','f','f','f','m'),
"33"=>array("",'f','m','m','m','f','f','f','m','f','f','f','m'),
"34"=>array("",'m','f','m','f','f','f','f','f','f','f','m','m'),
"35"=>array("",'m','m','f','m','f','f','f','m','f','f','m','m'),
"36"=>array("",'f','m','m','f','m','f','f','f','m','m','m','m'),
"37"=>array("",'m','f','m','m','f','m','f','m','f','m','f','m'),
"38"=>array("",'f','m','f','m','m','f','m','f','m','f','m','f'),
"39"=>array("",'m','f','m','m','m','f','f','m','f','m','f','f'),
"40"=>array("",'f','m','f','m','f','m','m','f','m','f','m','f'),
"41"=>array("",'m','f','m','f','m','f','m','m','f','m','f','m'),
"42"=>array("",'f','m','f','m','f','m','f','m','m','f','m','f'),
"43"=>array("",'m','f','m','f','m','f','m','f','m','m','m','m'),
"44"=>array("",'m','m','f','m','m','m','f','m','f','m','f','f'),
"45"=>array("",'f','m','m','f','f','f','m','f','m','f','m','m')
);
$new_years=array("2014"=>"January 31, 2014", "2015"=>"February 19, 2015", "2016"=>"February 9, 2016",
"2017"=>"January 28, 2017", "2018"=>"February 16, 2018", "2019"=>"February 5, 2019",
"2020"=>"January 25, 2020");
if(!empty($_POST['calculator_ok']))
{
// save in session to be used when the link "calculate again" is clicked
foreach($_POST as $key=>$var) $_SESSION["calc_".$key]=$var;
// calculate mother's lunar age
if (date("n") <= $_POST['month'])
{
// conceived this year
$year_conceived=date("Y")-1;
}
else
{
$year_conceived=date("Y");
}
$new_year=$new_years[$year_conceived];
// should I add 1 or 2 years to age?
if(strtotime($new_year)>strtotime($year_conceived."-".$_POST["month"]."-01"))
{
$addition=1;
}
else $addition=2;
$lunar_age=$_POST['age']+$addition;
// calculate the result
$result=$table[$lunar_age][$_POST['month']];
$gender=($result=='f')?"<span style=\"font-size:21px;font-weight:bold;color:pink;\">Girl</a></span>":"<span style=\"font-size:21px;font-weight:bold;color:lightblue\">Boy</span>";
//the result is here
?>
<div class="calculator_div">
<p align="center">Your lunar age of conception is <b><?=$lunar_age?></b>.</p>
<p align="center">You kid is most likely to be a <?=$gender?></p>
<p align="center"><a href="http://<?=$_SERVER['HTTP_HOST'];?><?=$_SERVER['REQUEST_URI']?>">Calculate again</a></p>
</div>
<?php
}
else
{
//the calculator comes here
?>
<div class="calculator_div">
<form method="post">
<p><label>Your age of conception:</label> <select name="age">
<?php for($i=16;$i<=43;$i++):
if($i==$_SESSION['calc_age']) $selected='selected';
else $selected='';
echo "<option $selected value='$i'>$i</option>";
endfor ?>
</select></p>
<p><label>Month of conception:</label> <select name="month">
<option value="1" <?if($_SESSION['calc_month']==1) echo "selected"?>>January</option>
<option value="2" <?if($_SESSION['calc_month']==2) echo "selected"?>>February</option>
<option value="3" <?if($_SESSION['calc_month']==3) echo "selected"?>>March</option>
<option value="4" <?if($_SESSION['calc_month']==4) echo "selected"?>>April</option>
<option value="5" <?if($_SESSION['calc_month']==5) echo "selected"?>>May</option>
<option value="6" <?if($_SESSION['calc_month']==6) echo "selected"?>>June</option>
<option value="7" <?if($_SESSION['calc_month']==7) echo "selected"?>>July</option>
<option value="8" <?if($_SESSION['calc_month']==8) echo "selected"?>>August</option>
<option value="9" <?if($_SESSION['calc_month']==9) echo "selected"?>>September</option>
<option value="10" <?if($_SESSION['calc_month']==10) echo "selected"?>>October</option>
<option value="11" <?if($_SESSION['calc_month']==11) echo "selected"?>>November</option>
<option value="12" <?if($_SESSION['calc_month']==12) echo "selected"?>>December</option>
</select></p>
<div style="text-align:center;clear:both;"><input type="submit" value="Calculate!"></div>
<input type="hidden" name="calculator_ok" value="1">
</form>
<p style="text-align:center;font-size:11px;"><a href="http://everydaybabies.com">Baby Photo Contest</a></p>
</div>
<?php
}
?>
答案 0 :(得分:1)
这正是错误所说的:你使用date()
函数而没有提供时区,根据PHP,这可能会导致时间错误。
事实上,在这一行:
if (date("n") <= $_POST['month'])
调用date()
函数,但未设置时区。
如果您可以控制php.ini设置,只需添加行
即可date.timezone=<your_default_timezone_identifier>
否则,如果你不能修改php.ini,只需添加行
date_default_timezone_set("<your_default_timezone_identifier>");
位于页面顶部。
答案 1 :(得分:0)
这些不是错误,只是警告。根据您的位置在php.ini中设置suitable date.timezone值并重新启动您的网络服务器。