PHP Tutorial : Validate email address – simple way with filter_var() function
Jul 26, 2009 Useful PHP
While browsing php.net without any scope I discovered a very cute & nice way to replace the usual regular expression email checking thing.
That way is via filter_var() php function which does the things 10 times faster :
<?php
$email = “someone@example.com”;
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo “Invalid email address”;
}
?>
Read PHP Tutorial : Validate email address – simple way with filter_var() function »
Dynamically create an image from any text in PHP
Jun 29, 2009 Useful PHP
My goal when I did this quick script was to use php to convert text into images, so that email addresses could be dynamically inserted into pages, making spam harvesters’ life a little harder.
Of course it has many more uses, one of them being to avoid web spiders from fetching a specific word…………….
Read Dynamically create an image from any text in PHP »
Tags: php convert text into image, php email to image, php merge text into image, php write text to an image, php write to image, Write text and convert into image
Find Browser Name and Capabilities in PHP
Jun 28, 2009 Useful PHP
To get the browser name just use this line:
<?php
print $_SERVER['HTTP_USER_AGENT'];
?>
And to get all the browser’s features use:
<?php
print_r(get_browser(null, true));//null for user agent and true to receive an array
?>
Read Find Browser Name and Capabilities in PHP »
Tags: php browser name, php detect visitor browser, php get browser, php get browser capabilities, php get user browser, php get user browser name, php get_browser, php get_browser() function
PHP Tutorial : Country list array
Jun 17, 2009 Useful PHP
In my point of view, a very useful and common thing we need when we build for example a membership site it’s country list array. I will do it within next function then will show how to use it :
Click here to get the function
And here’s how to use it for example to generate a…………….
Read PHP Tutorial : Country list array »
Tags: countries array, country array, php countries, php countries array, php country array, php country drop down, php country list, php country list array
PHP Tutorial : List function
Jun 16, 2009 Useful PHP
Beeing surprised that I didn’t write here about this “cute” php function called list(). I like it a lot, it’s like the extract() function in some way if you remember.
The list() php function will assign variables in one shot to strings from arrays.
<?php
//here's the php array
$countingArray = array(1,2,3);
//here, the list function will convert 1 to…………….
Read PHP Tutorial : List function »
Tags: assign variables, list, php convert string into variable, php list, php list function
PHP Tutorial : Get Protocol
Jun 2, 2009 Useful PHP
I saw this problem/question on a few forums and I finded it useful to post on my blog too due to low results on google that gives you what you need. So, how to get the protocol of a URL using php? Have a look :
<?php
$protocol = strtolower(substr($_SERVER["SERVER_PROTOCOL"],0,5))==’https’?'https’:'http’;
print “The protocol is $protocol”;
?>
Tadaaa!
Read PHP Tutorial : Get Protocol »
Tags: detect protocol, get protocol, php detect protocol, php get protocol, php protocol, protocol
PHP Tutorial : Ctype character type checking
Jun 1, 2009 Useful PHP
Happy 1st June for those under 18
Yesterday I’ve found a nice function in php called ctype. And? What it does? Well, I see it as a replacement for regular expressions. PHP Ctype function checks for character type. Let’s hear the chars type we can check with that nice function :
alphanumeric characters – ctype_alnum()
alphabetic characters …………….
Read PHP Tutorial : Ctype character type checking »
Tags: character type checking, check character type, ctype, ctype_alnum, ctype_alpha, ctype_cntrl, ctype_digit, ctype_graph, ctype_lower, ctype_print, ctype_punct, ctype_space, ctype_upper, ctype_xdigit, php character type, php ctype
PHP Tutorial : Get line number
May 31, 2009 Useful PHP
As you might know, PHP Server comes with built-in / already defined constants. Today I’ve been discovering a nice one which gets the line number in a file for you. This may be very usefull in a lot of cases, like a custom error system, debugging and not only. That CONSTANT is called simply _LINE_
<?php
print…………….
Read PHP Tutorial : Get line number »
Tags: built-in constant, php constants, php get line number, php line number, _LINE_, _LINE_ already defined constant
PHP Tutorial : Extract function
May 14, 2009 Useful PHP
A shame for me but I must tell you this function called extract() simply rocks : it will extract “keys” from an array and convert them into variables, so no more needed to manually declare variables for validation purposes from forms.
<form action="" method="post">
name <input type="text" name="name"><br/>
email <input type="text" name="email"><br/>
<input type="submit" name="sb" id="sb" value="go">
</form>
<?php
if(isset($_POST['sb'])) {
extract($_POST);
if(empty($name) ||…………….
PHP Tutorial : Create a RSS / XMLS Feed
Mar 28, 2009 Useful PHP
Welcome,
In this tutorial I will show you how to create a basic rss / xml feed with php. Basically, if you know how to create a feed in notepad, wordpad or whatever text editor, this will be easy. The difference between creating a php xml / rss feed and a “normal” one it’s that you…………….
Read PHP Tutorial : Create a RSS / XMLS Feed »
Tags: dynamic feed, feed, php dynamic feed, php dynamic rss xml feed, php feed, php feed header, php header, php rss xml feed, php xml feed, rss feed, rss header, rss xml feed, xml feed, xml header

