Why does the PHP variable disappear suddenly? I encountered a particularly strange problem. I used POST to get the data passed in a form and assign it to a variable. this variable was no problem when I first obtained it and printed it with echo, it can be displayed normally. But it disappears when the function is executed !!!
I thought it was caused by no pair in the process of variable conversion, but I did not take a look at it. The strange thing is:
Echo printed the variable before I used the strtotime function! Directly echo strtotime ($ time); no problem, but when I run $ time = strtotime ($ time); then I print the echo again and find it is empty !!! Empty !!!
PS: a magic thing happened before. the controller data has been correctly transmitted to the front-end page, but it is not displayed, as long as I have print_r ($ res) in the controller ); when printing this array, you can find that the corresponding position of the page is displayed !!!
Is this a bug in ecshop? Or what? Give me some advice!
Reply to discussion (solution)
Paste your code...
If so, didn't you pass the POST value? Submit the form again and try again!
Paste your code...
Set_charset ("utf8"); if (mysqli_connect_errno () {echo 'Error: cocould not connect to database. please try again later. '; exit;} if ($ act = 'ADD') {$ SQL = "insert into ecs_partners (partners, starttime, endtime, sort_order )". "values ('". $ partners. "',". $ starttime. ",". $ endtime. ",". $ sort_order. ")";} elseif ($ act = 'edit') {$ SQL = "update ecs_partners set partners = '". $ partners. "', starttime = ". $ starttime. ", end Time = ". $ endtime. ", sort_order = ". $ sort_order. "where id = ". $ id ;}$ res = $ db-> query ($ SQL); if ($ res) {echo "insert successful, jump 3 seconds later?
"; Echo" or ??? Directly jump? "; // Header (" Location: partners. php? Act = list "); header (" Refresh: 3; url = partners. php? Act = list ");} else {echo" Insert ?? Outbound ?,? Later ?.
"; Echo" or ?? Back to master? Face ";}$ db-> close () ;}?>
Paste your code...
Yes, I have tried it. I have tested it. I have output in front of it. after $ endtime = strtotime ($ endtime), the present value is blank after this step. I cannot explain it, I don't know why.
Paste your code...
I forgot to talk about it. The time is determined and processed by js, so I directly uploaded it.
$ Endtime = strtotime ($ endtime1 );
For the strtotime function: if the function is successful, the timestamp is returned; otherwise, FALSE is returned.
What is your $ endtime1 value ?? What is echo strtotime ($ endtime1 ??
$ Endtime = strtotime ($ endtime1 );
For the strtotime function: if the function is successful, the timestamp is returned; otherwise, FALSE is returned.
What is your $ endtime1 value ?? What is echo strtotime ($ endtime1 ??
It is a formatted time string:, and the converted timestamp is echo, which can be output normally.
The key is that the value assignment statement is empty when the variable is printed.
$ Endtime = strtotime ($ endtime1 );
For the strtotime function: if the function is successful, the timestamp is returned; otherwise, FALSE is returned.
What is your $ endtime1 value ?? What is echo strtotime ($ endtime1 ??
It is a formatted time string:, and the converted timestamp is echo, which can be output normally.
The key is that the value assignment statement is empty when the variable is printed.
I used your statement on my computer to test. The result is normal and there is no problem as mentioned by the landlord... Weird--is it null?
$ Endtime = strtotime ($ endtime1 );
For the strtotime function: if the function is successful, the timestamp is returned; otherwise, FALSE is returned.
What is your $ endtime1 value ?? What is echo strtotime ($ endtime1 ??
It is a formatted time string:, and the converted timestamp is echo, which can be output normally.
The key is that the value assignment statement is empty when the variable is printed.
I used your statement on my computer to test. The result is normal and there is no problem as mentioned by the landlord... Weird--is it null?
Well, I tried again and found that var_dump (strtotime ($ endtime) is changed to bool (false)
$ Endtime = strtotime ($ endtime1 );
For the strtotime function: if the function is successful, the timestamp is returned; otherwise, FALSE is returned.
What is your $ endtime1 value ?? What is echo strtotime ($ endtime1 ??
It is a formatted time string:, and the converted timestamp is echo, which can be output normally.
The key is that the value assignment statement is empty when the variable is printed.
I used your statement on my computer to test. The result is normal and there is no problem as mentioned by the landlord... Weird--is it null?
This is a strange thing, and the text cannot be clearly expressed. let me try to find another student.
Cannot understand ...... Let's take a look at it ......
$ Endtime = strtotime ($ endtime1 );
For the strtotime function: if the function is successful, the timestamp is returned; otherwise, FALSE is returned.
What is your $ endtime1 value ?? What is echo strtotime ($ endtime1 ??
It is a formatted time string:, and the converted timestamp is echo, which can be output normally.
The key is that the value assignment statement is empty when the variable is printed.
I used your statement on my computer to test. The result is normal and there is no problem as mentioned by the landlord... Weird--is it null?
Well, I tried again and found that var_dump (strtotime ($ endtime) is changed to bool (false)
Shouldn't var_dump be $ endtime1? if your $ endtime variable in dump does not exist, it must be false. are you confused about the variable name?
$ Endtime = strtotime ($ endtime1 );
For the strtotime function: if the function is successful, the timestamp is returned; otherwise, FALSE is returned.
What is your $ endtime1 value ?? What is echo strtotime ($ endtime1 ??
It is a formatted time string:, and the converted timestamp is echo, which can be output normally.
The key is that the value assignment statement is empty when the variable is printed.
I used your statement on my computer to test. The result is normal and there is no problem as mentioned by the landlord... Weird--is it null?
Day, I directly use the string var_dump (strtotime ('2017-01-01 ') to output it as false.
$ Endtime = strtotime ($ endtime1 );
For the strtotime function: if the function is successful, the timestamp is returned; otherwise, FALSE is returned.
What is your $ endtime1 value ?? What is echo strtotime ($ endtime1 ??
It is a formatted time string:, and the converted timestamp is echo, which can be output normally.
The key is that the value assignment statement is empty when the variable is printed.
I used your statement on my computer to test. The result is normal and there is no problem as mentioned by the landlord... Weird--is it null?
Well, I tried again and found that var_dump (strtotime ($ endtime) is changed to bool (false)
Shouldn't var_dump be $ endtime1? if your $ endtime variable in dump does not exist, it must be false. are you confused about the variable name?
Sorry, I changed the name again. Will this be related to the php version? The output timestamp is normal when I converted and printed the time from, but all the values above 40 are false, php5.6.11
This is a problem about the applicability of strtotime.
The manual includes:
It can be inferred that strtotime cannot process a date later than 2069
You shouldn't worry about this.
Is that the case ......
This is a problem about the applicability of strtotime.
The manual includes:
It can be inferred that strtotime cannot process a date later than 2069
You shouldn't worry about this.
Yes. I confirmed it on my classmate's computer.
Is that the case ......
What does it mean?
This is a problem about the applicability of strtotime.
The manual includes:
It can be inferred that strtotime cannot process a date later than 2069
You shouldn't worry about this.
Yes. I confirmed it on my classmate's computer.
You mean, can you print the timestamp after 2070 in strtotime ??
This is a problem about the applicability of strtotime.
The manual includes:
It can be inferred that strtotime cannot process a date later than 2069
You shouldn't worry about this.
Yes. I confirmed it on my classmate's computer.
You mean, can you print the timestamp after 2070 in strtotime ??
Nun, 2080 is acceptable. In addition, I can create a new file and print 2070 directly with strtotime, so I think it may be a php problem.
After reading the reply, it looks amazing ~
This is a problem about the applicability of strtotime.
The manual includes:
It can be inferred that strtotime cannot process a date later than 2069
You shouldn't worry about this.
Yes. I confirmed it on my classmate's computer.
You mean, can you print the timestamp after 2070 in strtotime ??
Nun, 2080 is acceptable. In addition, I can create a new file and print 2070 directly with strtotime, so I think it may be a php problem.
It may be a version or php configuration problem. Under normal circumstances, the variables will not be lost even if you can print them normally ..
This is a problem about the applicability of strtotime.
The manual includes:
It can be inferred that strtotime cannot process a date later than 2069
You shouldn't worry about this.
Yes. I confirmed it on my classmate's computer.
You mean, can you print the timestamp after 2070 in strtotime ??
Nun, 2080 is acceptable. In addition, I can create a new file and print 2070 directly with strtotime, so I think it may be a php problem.
It may be a version or php configuration problem. Under normal circumstances, the variables will not be lost even if you can print them normally ..
Maybe, I set up my own environment, but there are few changes. it is estimated that some modules have not been enabled.
Ps: I don't know if you have used php5.6.12. I tried it on several computers and found that there is no curl in phpinfo and only the author name is displayed.
Y2K38 vulnerability
Y2K38, also known as the Unix Millennium Bug, affects all 32-bit systems that use UNIX timestamp integers to record time in PHP and other programming languages. The maximum time that an integer variable can be saved is January 1, January 2038.
03:14:07 on the 19th. After this time is exceeded, the integer value will overflow. Starting from January 1, January 01, 1970, when the world standard time is reached at 03:14:07 on Tuesday 1, January 19, 2038, more than 2 ^ 31? 1. 2 ^ 31? 1 is
0x7FFFFFFF, I believe many programmers have read it. in a 32-bit system, this indicates the largest signed integer. If it is used to represent the number of seconds, it is about 68.1 years. it is exactly the number from 1970 to 2038 years.
Will the 64-bit system be affected?
Theoretically not. we strongly recommend that you perform a test. In a 64-bit system, the maximum date that can be saved is 21 times the current cosmic age ~ 29.2 billion years.
I am also a local 64-bit system, but I found that this problem also exists, but I have read that apache is a 32-bit system, so it is OK if it is not only a 64-bit system, apache can be avoided only when it is 64-bit.
Solve the problem on a 32-bit machine
PHP introduced a DateTime class from version 5.2 (experiment addition started in version 5.1, and some methods are extended in version 5.3 ).
I'm not sure if 64-bit apache can solve the problem. I am also checking the 64-bit apache download. I haven't figured it out yet. let's try it together.
Yes, should there be 64-bit apache? Haha
Y2K38 vulnerability
Y2K38, also known as the Unix Millennium Bug, affects all 32-bit systems that use UNIX timestamp integers to record time in PHP and other programming languages. The maximum time that an integer variable can be saved is January 1, January 2038.
03:14:07 on the 19th. After this time is exceeded, the integer value will overflow. Starting from January 1, January 01, 1970, when the world standard time is reached at 03:14:07 on Tuesday 1, January 19, 2038, more than 2 ^ 31? 1. 2 ^ 31? 1 is
0x7FFFFFFF, I believe many programmers have read it. in a 32-bit system, this indicates the largest signed integer. If it is used to represent the number of seconds, it is about 68.1 years. it is exactly the number from 1970 to 2038 years.
Will the 64-bit system be affected?
Theoretically not. we strongly recommend that you perform a test. In a 64-bit system, the maximum date that can be saved is 21 times the current cosmic age ~ 29.2 billion years.
I am also a local 64-bit system, but I found that this problem also exists, but I have read that apache is a 32-bit system, so it is OK if it is not only a 64-bit system, apache can be avoided only when it is 64-bit.
I chose 64-bit
Try echo strtotime ('2014/1/19 11:14:08 '); and echo strtotime ('2014/2/19 11:14:07'); can it be output on 07, and 08 won't work, the overflow problem is certain, but it cannot be solved by the win64-bit system. I haven't tested it yet! However, I think there should be no problem with linux 64-bit.
It seems that theoretically no, not the actual situation, no, I win64-bit, the software is also 64-bit, you say your friend can, you can ask his php version, check if it is the latest version. my php version is 5.5.15.
Try echo strtotime ('2014/1/19 11:14:08 '); and echo strtotime ('2014/2/19 11:14:07'); can it be output on 07, and 08 won't work, the overflow problem is certain, but it cannot be solved by the win64-bit system. I haven't tested it yet! However, I think there should be no problem with linux 64-bit.
I tried it. it's exactly the same as what you thought. there's nothing left in 08.
Try echo strtotime ('2014/1/19 11:14:08 '); and echo strtotime ('2014/2/19 11:14:07'); can it be output on 07, and 08 won't work, the overflow problem is certain, but it cannot be solved by the win64-bit system. I haven't tested it yet! However, I think there should be no problem with linux 64-bit.
I tried it. it's exactly the same as what you thought. there's nothing left in 08.
Besides, I use win7 64bit.
Try echo strtotime ('2014/1/19 11:14:08 '); and echo strtotime ('2014/2/19 11:14:07'); can it be output on 07, and 08 won't work, the overflow problem is certain, but it cannot be solved by the win64-bit system. I haven't tested it yet! However, I think there should be no problem with linux 64-bit.
I tried it. it's exactly the same as what you thought. there's nothing left in 08.
Besides, I use win7 64bit.
In Windows environments, versions earlier than PHP6 do not support 64-bit. This PHP official has confirmed this problem because PHP5 Windows version is a test version and there is no official version, this can be found on the official website.
To put it simply, in Windows, the intval of PHP5 only supports up to 2147483647, that is, only 32 bits. even if your system, WebServer, and PHP are all 64-bit versions, only 32-bit is supported.
Some people said on the Internet that 64-bit php still uses the 32-bit mode. only linux or Windows 64-bit php7 uses the 64-bit mode. I will go to php7 to see if I can solve this problem.
If you use a 64-bit Linux version of php, no problem will occur.
If you use a 64-bit Linux version of php, no problem will occur.
Building a centos + Nginx + php + mariadb server by using the source code has failed many times, which is already a serious blow.
If you use a 64-bit Linux version of php, no problem will occur.
Building a centos + Nginx + php + mariadb server by using the source code has failed many times, which is already a serious blow.
Continue to try,
Due to environment deployment and troubleshooting requirements, regardless of the company's size, rd must be able to undertake at least half of the O & M work,
In addition, I have never seen any PHP production environment
After testing, php7 can solve this problem, but php7 has not been officially released. I don't know if there are any other bugs.
If you use a 64-bit Linux version of php, no problem will occur.
Building a centos + Nginx + php + mariadb server by using the source code has failed many times, which is already a serious blow.
Continue to try,
Due to environment deployment and troubleshooting requirements, regardless of the company's size, rd must be able to undertake at least half of the O & M work,
In addition, I have never seen any PHP production environment
After testing, php7 can solve this problem, but php7 has not been officially released. I don't know if there are any other bugs.
Thank you very much. I will send my php version later.
Thank you!
Sorry, I am wrong. my classmates use CentOS5.4, 64-bit