I need to validate the email address of my users. Unfortunately, making a validator that conforms to standards is hard. Here is an example of a regex expression that tries to conform to the standard. …
.htaccess files, PHP, includes directories, and windows XAMPP configuration nightmare
XAMPP makes configuring a local LAMP stack for windows a breeze. So it’s quite disappointing that enabling .htaccess files is such a nightmare. My problem: I’ve got a PHP application that requires apache/php to search for an /includes/ directory contained within the application. To do this, .htaccess files must be allowed in Apache and the .htaccess file must specify exactly
Loading .sql files from within PHP
I’m creating an installation script for an application that I’m developing and need to create databases dynamically from within PHP. I’ve got it to create the database but now I need to load in …
How to find the foreach index?
Is it possible to find the foreach index? in a for loop as follows: $i will give you the index. Do I have to use the for loop or is there some way to get the index in the foreach loop? Answer $key is the index of each $array element
Convert from MySQL datetime to another format with PHP
I have a datetime column in MySQL. How can I convert it to the display as mm/dd/yy H:M (AM/PM) using PHP?
How do I find the MIME type of a file with PHP?
I have an index.php file which has to process many different file types. How do I guess the filetype based on the REQUEST_URI? If I request http://site/image.jpg, and all requests redirect through index.php, which looks like this How would I make that work correctly? Should I test based on the extension of the file requested, or is there a way
Chaining Static Methods in PHP?
Is it possible to chain static methods together using a static class? Say I wanted to do something like this: $value = TestClass::toValue(5)::add(3)::subtract(2)::add(8)::result(); . . . and …
glob() – sort array of files by last modified datetime stamp
I’m trying to display an array of files in order of date (last modified). I have done this buy looping through the array and sorting it into another array, but is there an easier (more efficient) way …
php String Concatenation, Performance
In languages like Java and C#, strings are immutable and it can be computationally expensive to build a string one character at a time. In said languages, there are library classes to reduce this …
When and why should $_REQUEST be used instead of $_GET / $_POST / $_COOKIE?
Question in the title. And what happens when all 3 of $_GET[foo], $_POST[foo] and $_COOKIE[foo] exist? Which one of them gets included to $_REQUEST? Answer I’d say never. If I wanted something to be set via the various methods, I’d code for each of them to remind myself that I’d done it that way – otherwise you might end up