KBD

Keith Devens .com

Monday, December 1, 2008 Flag waving
If you rely on scale up, you’ll probably get killed. You should always be relying on scale out. – Phil Smoot
← What Darwin had to say about EvolutionPHP-Nuke forks →

Daily link icon Monday, December 16, 2002

PHP articles

Revjim

I love PHP. I really do. I swear. I just really get tired of seeing so many "articles" and "tutorials" and "code examples" that are complete and utter shit written by people who claim to be "experts".

Nice. I don't remember seeing that PATH_INFO variable anywhere though. It's not in my phpinfo() when I run it. Hmm...

← What Darwin had to say about EvolutionPHP-Nuke forks →

Comments XML gif

Reverend Jim (http://revjim.net/) wrote:

It doesn't show up in your phpinfo() unless you actually USE it. For instance, if you visit http://test.revjim.net/php.php you see no mention of PATH_INFO. However, if you visit http://test.revjim.net/php.php/some/path/info/here, you'll see it.

∴ Reverend Jim | 16-Dec-2002 10:59pm est | http://revjim.net/ | #1122

Keith (http://www.keithdevens.com/) wrote:

Wow! I never knew that existed before. So you can really get a lot of the benefit of mod_rewrite by using that. This tip goes in my pocket for later Smiley

Keith | 16-Dec-2002 11:45pm est | http://www.keithdevens.com/ | #1123

Alister (http://abulman.co.uk) wrote:

I use PATH_INFO a lot - like this book review site.
http://www.newbookreviews.co.uk/books/export/javascript/usercat/10/1

Here, export is the program, and the rest are parameters - for example, I can change the javascript for 'xml', or php, for PHP serialised data.

∴ Alister | 17-Dec-2002 7:50am est | http://abulman.co.uk | #1129

Keith (http://www.keithdevens.com/) wrote:

Hey Alister, what do you use to get rid of the extension for 'export'? Do you use ForceType? I just noticed there's a DefaultType directive which can be used to do a similar thing, so I'm wondering what other ways there are to accomplish this.

Keith | 17-Dec-2002 8:38am est | http://www.keithdevens.com/ | #1131

Reverend Jim (http://revjim.net/) wrote:

Since it doesn't look like Alister is going to answer you, I will tell you one easy way.

It requires apache, but you do this (replacing [ and ] with < and > respectively):

[Files export]
ForceType application/x-httpd-php
[/Files]

Another way, which I think is REALLY slick, works only if you have ONE script that you wish to use as your "controller" to launch everything else. Let's assume that your controller is called controller.php and it resides in your document root. This example also requires Apache and additionally, mod_rewrite.

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ controller.php/$1

Both of the above examples are untested, but you get the idea, I think.

∴ Reverend Jim | 10-Jan-2003 4:20pm est | http://revjim.net/ | #1249

Keith (http://www.keithdevens.com/) wrote:

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\. dispatcher.php

Hey Jim, that's the text above is exactly what I use in my public_html .htaccess file (with some comments removed). A few notes: Right now I only check if the directory exists. If the directory exists I leave it alone. Also, if the file has a period in it, I leave it alone so "normal" files, either .gif's etc. or .php's will be unaffected by the content management system. Finally, instead of capturing the URL and passing it to the controller with $1, I just get the URL info from the environment in my "dispatcher.php" (which you named controller.php) Smiley

Thanks for the explanation of ForceType.

Keith | 10-Jan-2003 5:18pm est | http://www.keithdevens.com/ | #1251

Reverend Jim (http://revjim.net/) wrote:

Wow.

I think you and I are writing (or you're writing, and I'm thinking about writing) the same things.

Although, at this time, I have no code to offer, would you be interested in pooling our resources?

∴ Reverend Jim | 10-Jan-2003 5:26pm est | http://revjim.net/ | #1252

Keith (http://www.keithdevens.com/) wrote:

I would love to pool our resources Smiley

We seem to have pretty much the same goals... I just keep going back and forth with conceptual problems. When I get home later I'll send you an e-mail with a summary of what I have and some sample code.

Keith | 10-Jan-2003 9:13pm est | http://www.keithdevens.com/ | #1253

Keith (http://www.keithdevens.com/) wrote:

Yeah, I stayed over my friend's house. I'll hit you up later Smiley

Keith | 11-Jan-2003 3:23am est | http://www.keithdevens.com/ | #1254

Feel free to post a comment below. Please see my comment policy.

Formatting Rules (No HTML):

  • **bold**, *italic*, _underlined_, --strikeout--
  • "text"="url" creates a link, and URLs are auto-highlighted
  • Blockquote: Like e-mail, begin paragraph with > (greater-than sign)
  • Lists: begin paragraph with *,-, or + (unordered), or # (ordered)
  • Code block: ?!code:language=perl|php|sql|javascript|etc.{\n}...{\n}?!/code

:
(will be your IP address if blank)
: (optional)
(Will not be shown on site)

: (optional)
:

December 2008
SunMonTueWedThuFriSat
 123456
78910111213
14151617181920
21222324252627
28293031 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 5 posts

Recent comments XML

new⇒Free image hosting sites

Well, TinyPic has this in its​FAQ:

> Images and videos is in​your accoun...

Keith: Dec 1, 1:13am

new⇒Join a NameValueCollection into a querystring in C#

Well with a lamba expression, this​is what I came up​with:

?!code:csharp...

Gustaf Lindqvist: Nov 30, 4:38pm

Why no generic OrderedDictionary?

Check​http://www.codeproject.com/KB/recip​es/GenericOrderedDictionary.aspx?d...

Gabrielk: Nov 27, 6:57am

WhatIsMyIP.com

http://www.thesysteminfo.com is​another good alternate to​whatismp.com... I...

Kripz: Nov 26, 8:51pm

Girls, please don't get breast implants

Actually I think it's sweet when a​man loves a woman whether she's big​or n...

218.186.12.228: Nov 26, 9:40am

Generated in about 0.219s.

(Used 8 db queries)

mobile phone