Development Blog by Professionals
PHP
PHP mail validation function
Jul 8th
function valid_email($str)
{
return ( ! preg_match(“/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix”, $str)) ? FALSE : TRUE;
}
Custom Trigger View Recordset Data
Jul 7th
- For PHP:$_SESSION['kt_login_id'] = $tNG->getPrimaryKeyValue();
$_SESSION['kt_login_user'] = $tNG->getColumnValue(‘name_usr’); - For ASPVBScript:Session(“kt_login_id”) = tNG.getPrimaryKey
Session(“kt_login_user”) = tNG.getColumnValue(“name_usr”)
SET Trigger_Custom = Nothing - For ColdFusion:SESSION.kt_login_id = tNG.getPrimaryKeyValue();
SESSION.kt_login_user = tNG.getColumnValue (“name_usr”);
PHP – remove
tag from string
Jul 5th
<?
$content = “this is something with an <img src=\”test.png\”/> in it.”;
$content = preg_replace(“/<img[^>]+\>/i”, “(image) “, $content);
echo $content;
?>
The result is:
this is something with an (image) in it.
PHP datetime Format
Jun 24th
- The format of the outputted date string . See the formatting options below. There are also several predefined date constants that may be used instead, so for example DATE_RSS contains the format string ‘D, d M Y H:i:s’. More >
php number_format Decimal
Jun 22nd
<?php$number = 1234.56;
// english notation (default)
$english_format_number = number_format($number);
// 1,235// French notation
$nombre_format_francais = number_format($number, 2, ',', ' ');
// 1 234,56$number = 1234.5678;
// english notation without thousands seperator
$english_format_number = number_format($number, 2, '.', '');
// 1234.57?>
MySQL errors into PHP?
Apr 19th
Here are some examples of how to utilize mysql_error ()
mysql_connect("your.hostaddress.com",
"username", "password") or die(mysql_error())
This will return an error if there is a problem connecting to your MySQL database
$value = mysql_query($your_query)
or die("A MySQL error has occurred.<br />Your Query: " .
$your_query . "<br /> Error:
(" . mysql_errno() . ") " . mysql_error())
When you encounter an error, this will return your custom message (A MySQL error has occurred.<br />) followed by a line number, and the actual
thanks http://php.about.com/od/phpwithmysql/f/mysql_error.htm
How to redirect browser to https (ssl) in php
Apr 13th
How to redirect the browser to https when site is using http protocal in PHP?
First of all, you should know that SSL must be installed in the server. To redirect the browser to “https” , we must know that the site is using SSL or not at the moment. And for this, there is a server variable in PHP called “HTTPS”. $_SERVER['HTTPS'] returns “on” values when the site is using SSL connection. More >
Celebrating / eortologio GREEK
Mar 22nd
#Celebrating their name’s day:
feedUrl = “http://eortologio.gr/rss/si_el.xml” #today
#feedUrl = “http://eortologio.gr/rss/si_av_el.xml” #today – tomorrow
#feedUrl = “http://eortologio.gr/rss/si_av_me_el.xml” #today – tomorrow – the day after tomorrow
Determine execution time in PHP
Feb 5th
<!-- put this at the top of the page -->
<?php
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;
;?>
<!-- put other code and html in here -->
<!-- put this code at the bottom of the page -->
<?php
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = ($endtime - $starttime);
echo "This page was created in ".$totaltime." seconds";
;?>
.htaccess upload_max_filesize ini_set()
Jan 25th
I m PHP 5.2.0 / Apache
and I can’t access php.ini
I try to update .htaccess
and added
php_value upload_max_filesize “25M”
php_value post_max_size “25M”
However it will give me “Internal Server Error” More >


