Is there a place to find a list of the possible values for the PHP predefined constant PHP_OS ? I'd like to use this value for a system requirements check, but need to know how different operating systems are named in this variable.
Through some searching, so far I've compiled the following list:
CYGWIN_NT-5.1
Darwin
FreeBSD
HP-UX
IRI...
Take an example login() function within a class Account.
class Account {
/* Class variables */
public function login() {
if(isset($_POST['username'])
else if(isset($_SESSION['accountId']))
return $this->_sessionLogin();
else if(isset($_COOKIE['username'])
else return false;
}
...
Hi, I'm building a small abstract class that's supposed to make certain tasks easier.
For example:
$var = class::get('id');
would run check if there's pointer id in the $_GET, returning a string or array according to parameters. This should also work for post and request and maby more.
I'm doing it in the way there's function for all t...
I am trying to read get parameters in such a way that will not open up potential security issues.
What I was thinking was matching the request parameter explicitly to what I expect and then setting a default for anything that doesn't match.
For example:
if ($_REQUEST['media'] == "video")
$sort = "video";
elseif ($_REQUEST['media']...
Hi,
I am trying to get the entire page URL as a string in PHP - so, if the requested URL is ./foo.php?arg1=test&arg2=test2, I get "./foo.php?arg1=test&arg2=test2".
I know that I can get the ./foo.php part from $_SERVER and the variables from $_GET, but I was wondering if there's an easy way to do it in just one fell swoop.
TIA.
...
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?
...
I'm trying to transfer a large array between two sites in PHP. I'm the admin in both.
The array is created on one site, and after its creation I wish to automatically redirect the user to the other site, and pass the processed array along.
I cannot use the SESSION superglobal, as it is limited to a specific domain.
GET is not suitable...
Hey everyone, some background info:
In the config file for my website, I set the mysql database name, username and password based on the contents of $_SERVER['HTTP_HOST']. Because it is possible for this variable to not be set in the case of old (HTTP 1.0) requests and cron jobs, I include a file that spoofs the $_SERVER['HTTP_HOST'] va...
My url is something such as: "inventory.php?sorting=1" and so forth. Page loads fine but does not display the information properly.
mysql_connect("localhost","user","pass");
mysql_select_db("database");
if ($sorting == 1){
$result = mysql_query("select * from vehicles ORDER BY year DSC");
}
elseif ($sorting == 2){
$result = mysql_qu...
is this pointing to the directory where the current file is executed?
...
EDIT: (UPDATED)
Maybe my question was not clear enough. Ok, lets put it this way:
$arr["a"] = 10;
var_dump($arr);
$arr["b"] =& $arr["a"];
var_dump($arr);
the first var_dump returns:
array
'a' => int 10
While the second one returns:
array
'a' => &int 10
'b' => &int 10
If I unset($arr["a"]) it will return:
array
'b' => ...
Apparently there was confusion as to my original post so let me start over:
I am essentially creating an online shopping cart which gives a manager the ability to enroll his/her employees for training services which we provide. We charge $49 for the services for every employee enrolled. The primary difference between this and a traditio...
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";
} elsei...
What is the benefit of using the super global $_SERVER['PHP_SELF']?
...
So, I don't come from a huge PHP background—and I was wondering if in well formed code, one should use the 'superglobals' directly, e.g. in the middle of some function say $_SESSION['x'] = 'y'; or if, like I'd normally do with variables, it's better to send them as arguments that can be used from there, e.g:
class Doer {
private $se...
I'm trying to grab each URL parameter and display them from first to last, but I want to be able to display any of the parameters anywhere on the page. How can I do this? What do I have to add or modify on my script?
Here is an example of a URL value.
http://www.localhost.com/topics/index.php?cat=3&sub1=sub-1&sub2=sub-2&su...
As a web developer, I'm always using this approach to something like a login form or other “save” operation (ignoring the dangers of directly accessing input variables):
if (isset($_POST['action']) && $_POST['action'] == 'login')
{
// we're probably logging in, so let's process that here
}
To make this less tedious and keeping in ...
I'm probably being a little thick, but I can't seem to find an answer to this one. I'm moving from a server with register globals ON to one with it being off. It's a good thing, but unfortunately I have been used to years and years working with register globals being ON which has resulted in me writing sloppy code. I am now trying to fix...
I am getting tried of if isset($_GET['whatever'])... before the rest of my if statement. E_NOTICE errors are way to handy to turn off and for $_POST variables I have a solution in my init script..
$POST = (is_array( $_POST ) && count( $_POST ) > 0);
I find this helps self posting scripts look clean.
if ($POST) {
// now do somethi...
Hey!
I'm trying to add some sort of a superglobal in my app. It will only store a small integer, but I need it to be accessible from anywhere in my app.
I know you can use the delegate for this, but wouldn't it be easier if you could just set a superglobal in your application (of course it has to be alterable)?
So, what is the best wa...