.
WinWeb
Microsoft Windows Hosting, ASP, ASP.NET, Multiple Domain Name Plans
home
|
about us
|
contact us
Hosting web sites since 1997
WEB HOSTING
ECOMMERCE
DOMAIN NAMES
SUPPORT
REFERRAL PARTNERS
ORDER
LOGIN
For Phone Support Call:
1.212.753.1520
TOOLS
ASP Scripts
asp.NET Scripts
HTML Scripts
JAVA Scripts
PERL Scripts
PHP Scripts
WML Scripts
Support Tools
PHP Scripts
.
Date
/
File Write
/
Info
/
MapPath
/
MySQL connection
/
Random Session ID
/
Redirect by host name
/
Send email
/
Sort numbers
/
Date Time
.
..
Date
Hi, the date is: echo date("D M d, Y", time()); ?> - The time is: echo date("H:i:s", time()); ?> EDT . This looks like: Tue Jul 08, 2003 12:10:08 Formats: Y - Year eg. 2003 y - Year eg. 03 M - Month eg. Jul m - Month eg. 07 D - Day eg. Tue d - Day eg. 08 z - Day of the year eg. 188 H - Hours in 24 hour format eg. 12 h - Hours in 12 hour format eg. 12 i - Minutes eg. 10 s - Seconds eg. 08 U - Seconds since epoch eg. 1057680608
back to top
..
..
File Write
back to top
..
..
Info
back to top
..
..
MapPath
// For Windows / IIS servers // Return the absolute path to the current directory function current_dir($path) { //this here bellow trims the last / in case it has it If ($path{strlen($path)-1}=="/"){ $path = substr($path,0, strlen($path)-1); } $relative = $path; // transforms virtual or relative path to an absolute path return realpath(substr($path,0,1)=='/' ? $relative.substr($path,1) : $path); } $filename = 'somefile.php'; $realpath = current_dir($filename); // The result in $realpath would be something like // C:\Inetpub\wwwroot\website001\somefile.php ?>
back to top
..
..
MySQL connection
\n"; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { print "\t
\n"; foreach ($line as $col_value) { print "\t\t
$col_value
\n"; } print "\t
\n"; } print "
\n"; /* Free resultset */ mysql_free_result($result); /* Closing connection */ mysql_close($link); ?>
back to top
..
..
Random Session ID
/* ** generates a session id */ function SessionID($length=16) { /* ** Set pool of possible characters */ $Pool = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $Pool .= "abcdefghijklmnopqrstuvwxyz"; for($index = 0; $index < $length; $index++) { $sid .= substr($Pool, (rand()%(strlen($Pool))), 1); } return($sid); } /* ** Seed the generator */ srand(time()); if($sid != "") { print("Old Session ID was $sid
\n"); } $sid = SessionID(); print("
"); print("Get Another Session ID"); print("
\n"); ?>
back to top
..
..
Redirect by host name
back to top
..
..
Send email
//ini_set('sendmail_from', 'info@your-domain.com'); $from_email = "sender@your-domain.com"; $to ="info@your-domain.com"; $from = "From: $from_email\n"; $subject ="php test"; $body ="php test"; mail ( $to, $subject, $body, $from); print "mail sent"; ?>
back to top
..
..
Sort numbers
/* ** Quicksort ** input_array is an array of integers ** left is the leftmost element to be considered ** right is the rightmost element to be considered */ function Quicksort(&$input_array, $left_limit, $right_limit) { //start pointers $left = $left_limit; $right = $right_limit; //Choose the middle element for the pivot $pivot_point = intval(($left + $right)/2); $pivot = $input_array[$pivot_point]; do { while(($input_array[$left] < $pivot) AND ($left < $right_limit)) { $left++; } while(($pivot < $input_array[$right]) AND ($right > $left_limit)) { $right--; } if($left <= $right) { //swap elements $temp = $input_array[$left]; $input_array[$left] = $input_array[$right]; $input_array[$right] = $temp; $left++; $right--; } } while($left <= $right); if($left_limit < $right) { Quicksort(&$input_array, $left_limit, $right); } if($left < $right_limit) { Quicksort(&$input_array, $left, $right_limit); } } /* ** print text with an HTML line break */ function println($text) { print("$text
\n"); } $some_numbers = array(6, 13, 99, 2, 33, 19, 84); //print array print("
Unsorted
\n"); array_walk($some_numbers, "println"); //sort array Quicksort(&$some_numbers, 0, count($some_numbers)-1); //print array again print("
Sorted
\n"); array_walk($some_numbers, "println"); ?>
back to top
..
..
Date Time
\n"; } // Test the function with several values date_diff("1978-04-26", "2003-01-01"); date_diff("1984-10-24 15:32:25", "2003-01-01"); date_diff("2001-10-28 17:32:25", "2003-01-01 12:00:18"); ?>
back to top
..
30-Day Money Back Guarantee
|
Terms & Conditions
| © GeneralHosting.com/Winweb LLC., Official Microsoft Windows 2003 Hosting