superglobals

PHP Array key strings without quotation marks

僤鯓⒐⒋嵵緔 提交于 2020-06-28 01:47:07
问题 I am moving the files to the server and is using variables like $_GET[mode] without ''(single quotes) in 'mode'. It works perfectly locally but on the server i am getting notices.. How can i overcome this?here is my phpinfo file phpinfo Is there any way we can have same behavior to work on server as well? 回答1: How can you overcome the E_NOTICE s that complain that you forgot quotes around your strings? Add quotes around your strings. $_GET['mode'] Also it sounds like the error_reporting level

Client access to Superglobals

Deadly 提交于 2020-05-17 03:04:40
问题 PHP Superglobals behave in different ways and I'm never sure about which one to use. When can the client (I'm not talking about hackers or security attacks, but " normal users ") edit, create or access a Superglobal variable? Even php.net documentation does not talk about this fact. Basing on what I've learnt so far I can summarize them in this way: superglobal read create edit $_GET V V V $_POST X V X $_FILES X V X $_SESSION ? X X $_COOKIE V V V I'm not talking about your PHP script which

Client access to Superglobals

一个人想着一个人 提交于 2020-05-17 02:59:14
问题 PHP Superglobals behave in different ways and I'm never sure about which one to use. When can the client (I'm not talking about hackers or security attacks, but " normal users ") edit, create or access a Superglobal variable? Even php.net documentation does not talk about this fact. Basing on what I've learnt so far I can summarize them in this way: superglobal read create edit $_GET V V V $_POST X V X $_FILES X V X $_SESSION ? X X $_COOKIE V V V I'm not talking about your PHP script which

PHP Accessing the user's country (locale)

拟墨画扇 提交于 2020-02-02 13:48:27
问题 Is there a superglobal reference to the user's country or is using the IP against a database of IP to Country lookups the best way to go? 回答1: i wish there were such thing as $_SERVER['HTTP_COUNTRY'] ... maybe in php99 ? ;) for the time being, http://php.net/manual/en/book.geoip.php is your best bet however, if you're only interested in user's language, there is $_SERVER["HTTP_ACCEPT_LANGUAGE"] 回答2: Here are some more options for ip to country lookups http://www.hostip.info/ http://pear.php

PHP $_SERVER[‘SERVER_ADDR’] variable always returns 127.0.0.1

谁说我不能喝 提交于 2020-01-03 19:57:14
问题 We have multiple load-balanced webserver machines running the same PHP webapp (LAMP) and I'd like to run slightly different code on each server ( for testing purposes ). I was hoping to use the $_SERVER['SERVER_ADDR'] super global to do something like this: if ($_SERVER['SERVER_ADDR'] == 'XXX.XXX.XXX.XXX') { echo "Do one thing"; } elseif ($_SERVER['SERVER_ADDR'] == 'YYY.YYY.YYY.YYY') { echo "Do something else"; } Unfortunately, this doesn't work because both machines are setting $_SERVER[

is $_POST in php truly superglobal? [closed]

感情迁移 提交于 2019-12-25 00:21:52
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . Why am i asking this ? I'm trying hard to fathom php's superglobal concept ... array data/variables for $_POST are only available to

Access files posted through AJAX using $_FILES variable

泪湿孤枕 提交于 2019-12-24 14:28:19
问题 Trying to learn how to use the new AJAX file uploading, instead of using iframes or the good old PHP only file uploading. I understand how XHR requests work and have been using jQuery's $.post for a long time. But I can't get this one. The reason: when I post data (the file I want to upload) I can only access it through a $_POST global, not the required $_FILES global. Here's some of my code real quick: <input type="file" id="file"/> <input type="submit" id="submit" value="Upload" /> $("#file

What is the benefit of using the super global `$_SERVER['PHP_SELF']` in PHP?

岁酱吖の 提交于 2019-12-23 05:43:08
问题 What is the benefit of using the super global $_SERVER['PHP_SELF'] ? 回答1: $_SERVER['PHP_SELF'] doesn't (or shouldn't) include the domain name. It includes the path component of the url that the script was called from. Its use is primarily to introduce cross site scripting vulnerabilities. you can use it to fill in the action attribute of a form tag: <form method="post" action="<?=$_SERVER['PHP_SELF']?>"></form> If I then call your page with: your-file-that-uses-php-self.php/("><script>eval

At what point in the startup process does PHP set the REQUEST_TIME variables

扶醉桌前 提交于 2019-12-22 09:17:22
问题 As noted in the PHP documentation, the $_SERVER superglobal array contains two elements, REQUEST_TIME and REQUEST_TIME_FLOAT , both of which contain the timestamp of the start of the request, in varying precision levels. I am currently using the following snippet to include the time (in milliseconds) it took the server to generate the page in the footer of the page: round((microtime(true)-$_SERVER['REQUEST_TIME_FLOAT'])*1000,2); It returns an accurate value (can't really check, but it seems

What is the purpose of $_POST?

ぃ、小莉子 提交于 2019-12-20 04:56:06
问题 I know it is php global variable but I'm not sure, what it do? I also read from official php site, but did not understand. 回答1: You may want to read up on the basics of PHP. Try reading some starter tutorials. $_POST is a variable used to grab data sent through a web form. Here's a simple page describing $_POST and how to use it from W3Schools: PHP $_POST Function Basically: Use HTML like this on your first page: <form action="submit.php" method="post"> Email: <input type="text" name=