generic #rhgeootp without prescription, buy propranolol online generic, dynamicbusiness.com.au, purchase premarin online, #qazogped online uk, generic #lrrxbm, cheap #fugsiiyfnri

Categories

PHP date functions quick reference

checkdate()   Validates a Gregorian date
date_add()   Adds days, months, years, hours, minutes, and seconds to a date
date_create_from_format()   Returns a new DateTime object formatted according to a specified format
date_create()   Returns a new DateTime object
date_date_set()   Sets a new date
date_default_timezone_get()   Returns the default timezone used by all date/time functions
date_default_timezone_set()   Sets the default timezone used by all date/time functions
date_diff()   Returns the difference between two dates
date_format()   Returns a date formatted according to a specified format
date_get_last_errors()   Returns the warnings/errors found in a date string
date_interval_create_from_date_string()   Sets up a DateInterval from the relative parts of the string
date_interval_format()   Formats the interval
date_isodate_set()   Sets the ISO date
date_modify()   Modifies the timestamp
date_offset_get()   Returns the timezone offset
date_parse_from_format()   Returns an associative array with detailed info about a specified date, according to a specified format
date_parse()   Returns an associative array with detailed info about a specified date
date_sub()   Subtracts days, months, years, hours, minutes, and seconds from a date
date_sun_info()   Returns an array containing info about sunset/sunrise and twilight begin/end, for a specified day and location
date_sunrise()   Returns the sunrise time for a specified day and location
date_sunset()   Returns the sunset time for a specified day and location
date_time_set()   Sets the time
date_timestamp_get()   Returns the Unix timestamp
date_timestamp_set()   Sets the date and time based on a Unix timestamp
date_timezone_get()   Returns the time zone of the given DateTime object
date_timezone_set()   Sets the time zone for the DateTime object
date()   Formats a local date and time
getdate()   Returns date/time information of a timestamp or the current local date/time
gettimeofday()   Returns the current time
gmdate()   Formats a GMT/UTC date and time
gmmktime()   Returns the Unix timestamp for a GMT date
gmstrftime()   Formats a GMT/UTC date and time according to locale settings
idate()   Formats a local time/date as integer
localtime()   Returns the local time
microtime()   Returns the current Unix timestamp with microseconds
mktime()   Returns the Unix timestamp for a date
strftime()   Formats a local time and/or date according to locale settings
strptime()   Parses a time/date generated with strftime()
strtotime()   Parses an English textual datetime into a Unix timestamp
time()   Returns the current time as a Unix timestamp
timezone_abbreviations_list()   Returns an associative array containing dst, offset, and the timezone name
timezone_identifiers_list()   Returns an indexed array with all timezone identifiers
timezone_location_get()   Returns location information for a specified timezone
timezone_name_from_ abbr()   Returns the timezone name from abbreviation
timezone_name_get()   Returns the name of the timezone
timezone_offset_get()   Returns the timezone offset from GMT
timezone_open()   Creates new DateTimeZone object
timezone_transitions_get()   Returns all transitions for the timezone
timezone_version_get()   Returns the version of the timezone db
FacebookTwitterGoogle+PinterestTumblrStumbleUponRedditLinkedInWhatsAppBaiduBlinklistDeliciousDiggDiigoOdnoklassnikiPlurkWordPressBlogger PostEmailShare

PHP MySQli functions quick reference

mysqli_affected_rows()  Returns the number of affected rows in the previous MySQL operation
mysqli_autocommit()  Turns on or off auto-committing database modifications
mysqli_change_user()  Changes the user of the specified database connection
mysqli_character_set_name()  Returns the default character set for the database connection
mysqli_close()  Closes a previously opened database connection
mysqli_commit()  Commits the current transaction
mysqli_connect_errno()  Returns the error code from the last connection error
mysqli_connect_error()  Returns the error description from the last connection error
mysqli_connect()  Opens a new connection to the MySQL server
mysqli_data_seek()  Adjusts the result pointer to an arbitrary row in the result-set
mysqli_debug()  Performs debugging operations
mysqli_dump_debug_info()  Dumps debugging info into the log
mysqli_errno()  Returns the last error code for the most recent function call
mysqli_error_list()  Returns a list of errors for the most recent function call
mysqli_error()  Returns the last error description for the most recent function call
mysqli_fetch_all()  Fetches all result rows as an associative array, a numeric array, or both
mysqli_fetch_array()  Fetches a result row as an associative, a numeric array, or both
mysqli_fetch_assoc()  Fetches a result row as an associative array
mysqli_fetch_field_direct()  Returns meta-data for a single field in the result set, as an object
mysqli_fetch_field()  Returns the next field in the result set, as an object
mysqli_fetch_fields()  Returns an array of objects that represent the fields in a result set
mysqli_fetch_lengths()  Returns the lengths of the columns of the current row in the result set
mysqli_fetch_object()  Returns the current row of a result set, as an object
mysqli_fetch_row()  Fetches one row from a result-set and returns it as an enumerated array
mysqli_field_count()  Returns the number of columns for the most recent query
mysqli_field_seek()  Sets the field cursor to the given field offset
mysqli_field_tell()  Returns the position of the field cursor
mysqli_free_result()  Frees the memory associated with a result
mysqli_get_charset()  Returns a character set object
mysqli_get_client_info()  Returns the MySQL client library version
mysqli_get_client_stats()  Returns statistics about client per-process
mysqli_get_client_version()  Returns the MySQL client library version as an integer
mysqli_get_connection_stats()  Returns statistics about the client connection
mysqli_get_host_info()  Returns the MySQL server hostname and the connection type
mysqli_get_proto_info()  Returns the MySQL protocol version
mysqli_get_server_info()  Returns the MySQL server version
mysqli_get_server_version()  Returns the MySQL server version as an integer
mysqli_info()  Returns information about the most recently executed query
mysqli_init()  Initializes MySQLi and returns a resource for use with mysqli_real_connect()
mysqli_insert_id()  Returns the auto-generated id used in the last query
mysqli_kill()  Asks the server to kill a MySQL thread
mysqli_more_results()  Checks if there are more results from a multi query
mysqli_multi_query()  Performs one or more queries on the database
mysqli_next_result()  Prepares the next result set from mysqli_multi_query()
mysqli_num_fields()  Returns the number of fields in a result set
mysqli_num_rows()  Returns the number of rows in a result set
mysqli_options()  Sets extra connect options and affect behavior for a connection
mysqli_ping()  Pings a server connection, or tries to reconnect if the connection has gone down
mysqli_prepare()  Prepares an SQL statement for execution
mysqli_query()  Performs a query against the database
mysqli_real_connect()  Opens a new connection to the MySQL server
mysqli_real_escape_string()  Escapes special characters in a string for use in an SQL statement
mysqli_real_query()  Executes an SQL query
mysqli_reap_async_query()  Returns the result from async query
mysqli_refresh()  Refreshes tables or caches, or resets the replication server information
mysqli_rollback()  Rolls back the current transaction for the database
mysqli_select_db()  Changes the default database for the connection
mysqli_set_charset()  Sets the default client character set
mysqli_set_local_infile_default()  Unsets user defined handler for load local infile command
mysqli_set_local_infile_handler()  Set callback function for LOAD DATA LOCAL INFILE command
mysqli_sqlstate()  Returns the SQLSTATE error code for the last MySQL operation
mysqli_ssl_set()  Used to establish secure connections using SSL
mysqli_stat()  Returns the current system status
mysqli_stmt_init()  Initializes a statement and returns an object for use with mysqli_stmt_prepare()
mysqli_store_result()  Transfers a result set from the last query
mysqli_thread_id()  Returns the thread ID for the current connection
mysqli_thread_safe()  Returns whether the client library is compiled as thread-safe
mysqli_use_result()  Initiates the retrieval of a result set from the last query executed using the mysqli_real_query()
mysqli_warning_count()  Returns the number of warnings from the last query in the connection
FacebookTwitterGoogle+PinterestTumblrStumbleUponRedditLinkedInWhatsAppBaiduBlinklistDeliciousDiggDiigoOdnoklassnikiPlurkWordPressBlogger PostEmailShare

Remove a directory and contents

Remove a directory and contents , use with care

function rmdir_recursive($dir){
  $files = scandir($dir);
  foreach ($files as $file) {
    if ($file == '.' OR $file == '..') continue;
    $file = "$dir/$file";
    if (is_dir($file)) {
      rmdir_recursive($file);
      rmdir($file);
    } else {
      unlink($file);
    }
  }
  rmdir($dir);
}
FacebookTwitterGoogle+PinterestTumblrStumbleUponRedditLinkedInWhatsAppBaiduBlinklistDeliciousDiggDiigoOdnoklassnikiPlurkWordPressBlogger PostEmailShare

Image resize function example

This was a user submission a while back, lost the details but its a nice, useful function

function resizeImage( $file, $thumbpath, $max_side = NULL , $fixfor = NULL, $cropped = false ) {
 
			// 1 = GIF, 2 = JPEG, 3 = PNG
 
		if ( file_exists( $file ) ) {
			$type = getimagesize( $file );
 
			if (!function_exists( 'imagegif' ) && $type[2] == 1 ) {
				$error = __( 'Filetype not supported. Thumbnail not created.' );
			}
			elseif (!function_exists( 'imagejpeg' ) && $type[2] == 2 ) {
				$error = __( 'Filetype not supported. Thumbnail not created.' );
			}
			elseif (!function_exists( 'imagepng' ) && $type[2] == 3 ) {
				$error = __( 'Filetype not supported. Thumbnail not created.' );
			} else {
 
				// create the initial copy from the original file
				if ( $type[2] == 1 ) {
					$image = imagecreatefromgif( $file );
				}
				elseif ( $type[2] == 2 ) {
					$image = imagecreatefromjpeg( $file );
				}
				elseif ( $type[2] == 3 ) {
					$image = imagecreatefrompng( $file );
				}
 
				if ( function_exists( 'imageantialias' ))
					imageantialias( $image, TRUE );
 
				$image_attr = getimagesize( $file );
				$max_side = $max_side ? $max_side : $image_attr[0]; 
				// figure out the longest side
			if($fixfor){
					if($fixfor == 'width'){
						$image_width = $image_attr[0];
					$image_height = $image_attr[1];
					$image_new_width = $max_side;
 
					$image_ratio = $image_width / $image_new_width;
					$image_new_height = $image_height / $image_ratio;
					}elseif($fixfor == 'height'){
					 $image_width = $image_attr[0];
					$image_height = $image_attr[1];
					$image_new_height = $max_side;
 
					$image_ratio = $image_height / $image_new_height;
					$image_new_width = $image_width / $image_ratio;	
					}
			}elseif($cropped){
			  $image_new_width = $max_side*2;
			  $image_ratio = $image_attr[0] / $image_new_width;
			  $image_new_height = $image_attr[1] / $image_ratio;
 
			  $image_resized_crop = imagecreatetruecolor( $image_new_width, $image_new_height);
			  @imagecopyresampled( $image_resized_crop, $image, 0, 0, 0, 0, $image_new_width, $image_new_height, $image_attr[0], $image_attr[1] );
 
			  $cropX = intval((imagesx($image_resized_crop) - $max_side) / 2);
			  $cropY = intval((imagesy($image_resized_crop) - $max_side) / 2);
 
			}else{
				if ( $image_attr[0] > $image_attr[1] ) {
					$image_width = $image_attr[0];
					$image_height = $image_attr[1];
					$image_new_width = $max_side;
 
					$image_ratio = $image_width / $image_new_width;
					$image_new_height = $image_height / $image_ratio;
					//width is > height
				} else {
					$image_width = $image_attr[0];
					$image_height = $image_attr[1];
					$image_new_height = $max_side;
 
					$image_ratio = $image_height / $image_new_height;
					$image_new_width = $image_width / $image_ratio;
					//height > width
				}
			}	
 
 
				if(!$cropped){
					$thumbnail = imagecreatetruecolor( $image_new_width, $image_new_height);
					@imagecopyresampled( $thumbnail, $image, 0, 0, 0, 0, $image_new_width, $image_new_height, $image_attr[0], $image_attr[1] );
				}elseif($cropped){
					$thumbnail = imagecreatetruecolor( $max_side, $max_side);
					@imagecopyresampled( $thumbnail, $image_resized_crop, 0, 0, $cropX, $cropY, $max_side, $max_side, $max_side, $max_side);				
				}
 
				if (!imagejpeg( $thumbnail, $thumbpath ) ) {
						$error = 0;
					}
			}
		} else {
			$error = 0;
		}
 
		if (!empty ( $error ) ) {
			return $error;
		} else {
			return $thumbpath;
		}
	}
FacebookTwitterGoogle+PinterestTumblrStumbleUponRedditLinkedInWhatsAppBaiduBlinklistDeliciousDiggDiigoOdnoklassnikiPlurkWordPressBlogger PostEmailShare

Shorten a string function

A simple function to shorten a string

function shortenstring($txt,$size){
 
$short = $size - 3;
if(strlen($txt) > $size){
$data = substr( $txt, 0, $short )."...";
}
else
{
$data = $txt;
}
 
return $data;
}
 
 
echo shortenstring('The string to be shortened',15);

 

FacebookTwitterGoogle+PinterestTumblrStumbleUponRedditLinkedInWhatsAppBaiduBlinklistDeliciousDiggDiigoOdnoklassnikiPlurkWordPressBlogger PostEmailShare