- checkdate – It checks whether the date is valid or not
- date_add – Its an alias of DateTime::add()
- date_create_from_format – Its an alias of DateTime::createFromFormat()
- date_create – Its an alias of DateTime::__construct() and creates new DateTime object
- date_date_set – Its an alias of DateTime::setDate() and sets the date.
- date_default_timezone_get – Gets the default timezone used
- date_default_timezone_set – It can be used to set the time zone
- date_diff – It is an alias of DateTime::diff()
- date_format – It is an alias of DateTime::format()
- date_get_last_errors – It is an alias of DateTime::getLastErrors()
- date_interval_create_from_date_string – Alias of DateInterval::createFromDateString()
- date_interval_format – It is an Alias of DateInterval::format()
- date_isodate_set – It is an alias of DateTime::setISODate()
- date_modify – It an alias of DateTime::modify()
- date_offset_get – its an alias of DateTime::getOffset()
- date_parse_from_format – It returns details about given date
- date_parse – It returns associative array with detailed info about given date
- date_sub – Its an alias of DateTime::sub()
- date_sun_info – It Returns information about sunset/sunrise and twilight begin/end
- date_sunrise – It returns time of sunrise for a given day and location
- date_sunset – It returns time of sunset for a given day and location
- date_time_set – Its an alias of DateTime::setTime() and it sets the time
- date_timestamp_get – Its an alias of DateTime::getTimestamp()
- date_timestamp_set– Its an alias of DateTime::setTimestamp()
- date_timezone_get – Its an alias of DateTime::getTimezone()
- date_timezone_set – Its an alias of DateTime::setTimezone()
- date – It can be used to format the date/time of the server .
- getdate – It returns date/time details
- gettimeofday – It returns the current time.
- gmdate – Its similar to datefunction but formats GMT
- gmmktime – It returns Unix timestamp for a GMT date
- gmstrftime – it formats a GMT/UTC time/date according to locale settings
- idate – It formats a local time/date as integer
- localtime – It returns the local time
- microtime – It return current Unix timestamp with microseconds
- mktime – It returns Unix timestamp for a date
- strftime – It formats a local time/date according to locale settings
- strptime – it parses time/date generated with strftime()
- strtotime – it converts date/time into a Unix timestamp
- time – It returns current Unix timestamp
- timezone_abbreviations_list – Its an alias of DateTimeZone::listAbbreviations()
- timezone_identifiers_list – Its an alias of DateTimeZone::listIdentifiers()
- timezone_location_get – Its an alias of DateTimeZone::getLocation()
- timezone_name_from_abbr – It Returns the timezone name from abbreviation
- timezone_name_get – Its an alias of DateTimeZone::getName()
- timezone_offset_get – Its an alias of DateTimeZone::getOffset()
- timezone_open – Its an alias of DateTimeZone::__construct()
- timezone_transitions_get – Its an alias of DateTimeZone::getTransitions()
- timezone_version_get – It returns the version of the timezonedb
Tag Archives: PHP
Generate Random Number
<?php echo rand(1, 10) ?>
How to get article title
<?php
$id= JRequest::getVar(‘id’);
$objTitle = $article->load($id);
echo $objTitle->get(‘title’);
?>
How to get article id
<?php echo JRequest::getVar(‘id’); ?>
Magento
Magento is an e-commerce platform created on open source technology, which provides online merchants with an exceptional flexibility and control over the content, look and functionality of their e-commerce store.
Magento is an open-source content management system for e-commerce web sites. The software was originally developed by Varien Inc., a US private company headquartered in Culver City, California, with assistance from volunteers.
Varien published the first general-availability release of the software on March 31, 2008, under the name Bento. Roy Rubin, former CEO of Varien, later sold a substantial share of the company to eBay, which is now the sole owner.
According to research conducted by aheadWorks in October 2014, Magento’s market share among the 30 most popular e-commerce platforms is about 30%.
Magento employs the MySQL relational database management system, the PHP programming language, and elements of the Zend Framework. It applies the conventions of object-oriented programming and model-view-controller architecture. Magento also uses the entity–attribute–value model to store data.
Find the position of a character in a string
We can find out the position using the function strpos() that will return the position of a character
Example
<?php
$string=”phpcodez.com”;
echo strpos($string,”.”) // 8
?>
register_long_arrays
Its a flag and if its value is set to one we must use the longer version of the variable
| Array Name | Longer version of the name |
| $_POST | $HTTP_POST_VARS |
| $_FILES | $HTTP_POST_FILES |
| $_GET | $HTTP_GET_VARS |
| $_COOKIE | $HTTP_COOKIE_VARS |
| $_ENV | $HTTP_ENV_VARS |
| $_SERVER | $HTTP_SERVER_VARS |
| $_SESSION | $HTTP_SESSION_VARS |
Its not at all a convenient option , so its always better to have the value set to off
Unicode
Unicode is a computing industry standard for the consistent encoding, representation and handling of text expressed in most of the world’s writing systems. Developed in conjunction with the Universal Character Set standard and published in book form as The Unicode Standard, the latest version of Unicode consists of a repertoire of more than 109,000 characters covering 93 scripts, a set of code charts for visual reference, an encoding methodology and set of standard character encodings, an enumeration of character properties such as upper and lower case, a set of reference data computer files, and a number of related items, such as character properties, rules for normalization, decomposition, collation, rendering, and bidirectional display order
Unicode can be implemented by different character encodings. The most commonly used encodings are UTF-8, the now-obsolete UCS-2, and UTF-16. UTF-8 uses one byte for any ASCII characters, which have the same code values in both UTF-8 and ASCII encoding, and up to four bytes for other characters. UCS-2 uses two bytes for each character but cannot encode every character in the current Unicode standard. UTF-16 extends UCS-2, using four bytes to handle each of the additional characters.
php6 features
- Unicode
- Alternative PHP Cache
- Namespaces
- late static binding
- mysqlnd
- breaking to a label
- foreach on multidimensional arrays
- improvements to []
Namespaces
Namespaces is a method with which we can group variable,function or objects so that we can have more than one variable or function or object with same name .
Namespaces were introduced into PHP from version 5.3 onwards
Use
• Helps to prevent accidentally re-defining functions, classes, constants, …
• Avoids having to use long, highly descriptive class names
• Constants, classes, traits, interfaces and functions are affeced by the use of namespaces
• Create sub-namespaces to sub-divide a library
Declaring Namespaces
• Must declare the use of namespaces with the keyword “namespace” at the beginning of the code file (right after <?PHP)
• Use one namespace per code file (best practice)
• Unless a namespace is defined, constants, classes, functions, traits and interfaces are defined with the global namespace
• Within a namespace qualifying with a “\” references the global namespace
• Once code elements within a single namespace are defined, they can be used in other php files
Example
<?php
namespace php;
class php
{
public function phpcodez()
{
echo 'Function1 <br />';
}
}
namespace codez;
class codez
{
public function phpcodez()
{
echo 'Function2 <br />';
}
}
$phpcodez = new phpphp();
$phpcodez->phpcodez();
$phpcodez = new codezcodez();
$phpcodez->phpcodez();
?>