Main Contents

Debugging variables, GET, POST, SESSION, SERVER, ENV

<pre>
function variable_array_dump($VARIABLE_NAME, $VARIABLE_ARRAY){
if (is_array($VARIABLE_ARRAY)) {
$output = “<table border=’1′>”;
$output .= “<head><tr><td><b>” . $VARIABLE_NAME . “</b></td><td><b>VALUE</b></td></tr></head><body>”;
foreach ($VARIABLE_ARRAY as $key => $value) {
$value = variable_array_dump($key, $value);
$output .= “<tr><td>$key</td><td>$value</td></tr>”;
}
$output .= “</body></table>”;
return $output;
} else {return strval($VARIABLE_ARRAY);}
}
echo variable_array_dump(’GLOBAL GET’, $_GET);
echo variable_array_dump(’GLOBAL POST’, $_POST);
echo variable_array_dump(’GLOBAL COOKIE’, $_COOKIE);
echo variable_array_dump(’GLOBAL REQUEST’, $_REQUEST);
echo variable_array_dump(’GLOBAL ENV’, $_ENV);
echo variable_array_dump(’GLOBAL SERVER’, $_SERVER);
</pre>

Filed under: Uncategorized | Comments (0)

Custom 404 redirect with .htaccess

RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1

The first RewriteCond checks if the requested URL exists as a file on the filesystem. In mod_rewrite, -f refers to a file, while the bang is the “not” operator. Therefore, !-f means “if the request script filename does not exist as a file”.

If the first rewrite_cond succeeds (that is, the requested file wasn’t found), then Apache moves on to the next condition. The !-d directive means it the condition succeeds if the requested script does correspond to an existing directory on the server.

Finally, if both conditions succeed, the request is forwarded to the index.php file, as specified in the RewriteRule directive.

You can now access request POST data.

Filed under: Uncategorized | Comments (0)

Detecting a mobile browser

I have often looked at my sites on my mobile.  Some look good, others look really bad - usually down to some clever fancy-arse stuff that wouldn’t even work on a mobile.

So, I have finally found this article that reckons it is sussed.  I’m gonna try it out.

if(checkmobile()) {
header(”Location:http://www.whatever-url-you-want.com”);
}

(more…)

Filed under: HTML, PHP | Comments (0)

CSS fixes for IE, using Javascript

Some CSS effects dont work in IE, damn them, so that leaves 2 options.

Either forget that you have coded some nice roll-over effects that the majority of people wont see…

Or, add an IE-specific javascript fix.

<!–[if IE]>
<script type=”text/javascript” src=”/content/iehover-fix.js”></script>
<![endif]–>

Filed under: Uncategorized | Comments (0)

Shortcut Icon (favicon.ico)

In short, a 16x16px bitmap, renamed.  Or is it?

Use this code to in the <head> section to add it..
<link rel="shortcut icon" 
      href="favicon.ico"
      type="image/x-icon">
<link rel="icon" href="favicon.ico" />

Filed under: HTML | Comments (0)

css in forms, depending on [type]

This needs more details, but in short:

input[type="text"] {}   will work in FF, IE7+

input, textarea {}  will work for generic borders, etc..

otherwise, a ‘class’ can be used…

Filed under: CSS | Comments (0)

Semi-transparent backgrounds

OK - two methods.

1 - Using a transparent .gif (or .png **) as a background.  Guaranteed.

2 - CSS filters.

Each has its ads and disads.  More details to follow.

CSS

#transparentDivName {
filter: alpha(opacity=50);
-moz-opacity: 0.5;
opacity: 0.5;
}

 

IE6 has no support for transparent PNG’s

Alpha Transparency works well in most browsers; unfortunately, to have it work in Internet Explorer versions 5.5  and 6, we need to add an additional style and set a filter property, which is proprietary to Internet Explorer.

We can use conditional comments (also a proprietary IE feature) to serve up additional styles to Internet

Explorer versions earlier than 7:

<!--[if lt IE 7]>
<style type="text/css">
.captioned_photo p {
background: none;
filter:progid:DXImageTransform.Microsoft.AlphaImageLoader
(sizingMethod=scale, src='images/caption-white.png');
}
</style>
<![endif]-->

 

The filter used in this CSS example can’t be paired with a background, as that background will be used instead, without alpha transparency. You can put this rule in a separate, external style sheet, instead of embedding the styles, if you so choose, though adding another HTTP request for such a small addition is likely to slow down your site.

Filed under: CSS | Comments (0)

CSS3 and Rounded borders…

…but still not on IE.

<div style=" background-color: #ccc;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border: 1px solid #000;
padding: 10px;" >

(more…)

Filed under: CSS | Comments (0)

Search, with no click

How do you style a search button?  They all look crap to me, and the default browser ones are all different.  So, my solution is to get rid of it.  Gone.  No button.    Heres how…

(more…)

Filed under: HTML, Javascript | Comments (0)

Where am I…?

$path = $_SERVER['PHP_SELF'];
$file = basename($path); // $file is set to “index.php”
$file = basename($path, “.php”); // $file is set to “index”

(str path [,str suffix])

path
A path.
n Windows, both slash (/) and backslash (\) are used as directory separator character. In other environments, it is the forward slash (/).
suffix
If the filename ends in suffix this will also be cut off.

Filed under: PHP | Comments (0)