Short Tag – Web Development Blog

Entries for May, 2010

PHP redirects, 301 redirect with PHP

You might know that there are 2 kinds of redirects. A temporary redirect and a permanent one. The user or programming experience does not change if you are using one or the other but choosing the right redirect type has a great importance for SEO.
301 – permanent redirect
302 – temporary redirect
The idea is that permanent [...]

file_get_contents() timeout in PHP

Though file_get_contents is not so advanced as CURL we can use it in lots of situations. In case you use file_get_contents and you need to set for how long to try to make connection you can use stream context.
First we create the stream context:
$sc = stream_context_create(array( ‘http’ => array( [...]

Override functions in PHP

IF you have APD (Advanced PHP Debugger) extension enabled in PHP you can override a function (or more).
The function that helps you achieve this:
bool override_function ( string $function_name , string $function_args , string $function_code )
override_function(‘myfunction’, ’$first,$last’, ’echo ”Result: “; return $first * $last;’);
This can be very handy when you have an entire script that [...]

Force server to parse old .INC files, Add Extension Handler in Apache

If we use some older script we might notice that they use files with extensions, like .inc. Some servers do parse these files only if they are included from .php files, if accessed directly the server will display them as regular text files. Depending on the script this could be a big security issue.
So we [...]