# Simple PHP question

**URL:** https://boards.straightdope.com/t/simple-php-question/322391
**Category:** Factual Questions
**Created:** [September 19, 2005, 6:04pm UTC](https://boards.straightdope.com/t/simple-php-question/322391 "2005-09-19T18:04:55Z")
**Posts on this page:** 7
**Page:** 2

<div class="post-metadata">

### Author: ![Walton\_Firm](https://avatars.discourse-cdn.com/v4/letter/w/45deac/32.png) [@Walton\_Firm](https://boards.straightdope.com/u/Walton_Firm)
#### Post date: [September 19, 2005, 7:31pm UTC](https://boards.straightdope.com/t/simple-php-question/322391/21 "2005-09-19T19:31:59Z")

</div>

By the way, an alternative method is to use the [import\_request\_variables](http://nl3.php.net/manual/en/function.import-request-variables.php) method. It will import all of the name/value pairs from the HTTP request into your global variable space, same as before, but give them a prefix so that they can’t clash with the other variables in your script.

For example:

```auto

<?php
import_request_variables("gp", "req_");

echo 'meret='.filesize($req_filename) . "&ended=igen";
?>

```

Now, as long as you make sure that none of your variable names start with the **req\_** prefix, except when you actually intend to refer to the GET or POST request, you can have all the convenience of automatic globals, without the security risks.

---

<div class="post-metadata">

### Author: ![pulykamell](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/pulykamell/32/3166_2.png) [@pulykamell](https://boards.straightdope.com/u/pulykamell)
#### Post date: [September 19, 2005, 7:45pm UTC](https://boards.straightdope.com/t/simple-php-question/322391/22 "2005-09-19T19:45:24Z")

</div>

> [@Walton Firm](#):
>
> On a UNIX-like machine (e.g. FreeBSD or Linux), the php.ini file is typically located in the /etc directory.

I assume I access this through telnet?

---

<div class="post-metadata">

### Author: ![Walton\_Firm](https://avatars.discourse-cdn.com/v4/letter/w/45deac/32.png) [@Walton\_Firm](https://boards.straightdope.com/u/Walton_Firm)
#### Post date: [September 19, 2005, 7:54pm UTC](https://boards.straightdope.com/t/simple-php-question/322391/23 "2005-09-19T19:54:04Z")

</div>

> [@pulykamell](#):
>
> I assume I access this through telnet?

I don’t know. But if you have to ask that question, you are presumably not the admin of the machine in question, which means that you almost certainly don’t have write permission to the /etc directory.

You could still try putting a php.ini in the web-root. However, you don’t need to, because either of the two scripts I gave in my last posts will work independently of the setting of register\_globals, so you should just leave it disabled.

(By the way, register\_globals isn’t _that_ dangerous – it’s not as if merely having it enabled will, by itself, open up your machine to attacks. However, in larger programs it can allow hackers to insert stuff into your program’s variables in unexpected and undesired ways. And anyway, explicitly initializing your program’s input, instead of just dumping the contents of the GET/POST request into the global variable space, is just basic good programming practice: it makes your code more readable by showing explicitly what values the program expects. Not that it matters for a two-line script like this, of course, but you might as well get used to doing things the right way.)

---

<div class="post-metadata">

### Author: ![pulykamell](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/pulykamell/32/3166_2.png) [@pulykamell](https://boards.straightdope.com/u/pulykamell)
#### Post date: [September 19, 2005, 8:00pm UTC](https://boards.straightdope.com/t/simple-php-question/322391/24 "2005-09-19T20:00:54Z")

</div>

> [@Walton Firm](#):
>
> I don’t know. But if you have to ask that question, you are presumably not the admin of the machine in question, which means that you almost certainly don’t have write permission to the /etc directory.

_shrug_ I don’t know. It’s my account, it’s web server space hosted at A Plus Net.  
I have very little knowledge of how these things work beyond HTML. Last time I used telnet and UNIX was in my university days.

---

<div class="post-metadata">

### Author: ![pulykamell](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/pulykamell/32/3166_2.png) [@pulykamell](https://boards.straightdope.com/u/pulykamell)
#### Post date: [September 19, 2005, 8:12pm UTC](https://boards.straightdope.com/t/simple-php-question/322391/25 "2005-09-19T20:12:15Z")

</div>

I figured it out.

---

<div class="post-metadata">

### Author: ![Walton\_Firm](https://avatars.discourse-cdn.com/v4/letter/w/45deac/32.png) [@Walton\_Firm](https://boards.straightdope.com/u/Walton_Firm)
#### Post date: [September 19, 2005, 8:14pm UTC](https://boards.straightdope.com/t/simple-php-question/322391/26 "2005-09-19T20:14:10Z")

</div>

Congratulations! Nice site, by the way – cool photos.

---

<div class="post-metadata">

### Author: ![pulykamell](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/pulykamell/32/3166_2.png) [@pulykamell](https://boards.straightdope.com/u/pulykamell)
#### Post date: [September 19, 2005, 9:29pm UTC](https://boards.straightdope.com/t/simple-php-question/322391/27 "2005-09-19T21:29:11Z")

</div>

> [@Walton Firm](#):
>
> Congratulations! Nice site, by the way – cool photos.

Oh, it’ll get cooler. 🙂 It’s not quite a random collection of images up there, but still a little ways from being complete.

[Previous page](https://boards.straightdope.com/t/simple-php-question/322391.md?page=1)
