Blog: Extra-ordinary

What are the different types of errors in php?

What are the different types of errors in php? Notices: These are trivial, non-critical errors that PHP encounters while executing a script – for example, accessing a variable that has not yet been defined. By default, such errors are not displayed to the user at all – although, as you will see, you can change this default behaviour. Warnings: These …

Continue Reading

Explain include(), include_once, require() and require_once.

Explain include(), include_once, require() and require_once: include() The include() function takes all the content in a specified file and includes it in the current file. If an error occurs, the include() function generates a warning, but the script will continue execution. include_once() File will not be included more than once. If we want to include a file once only and …

Continue Reading

How can convert the time zones using PHP?

date_default_timezone_set function on PHP 5.1.0 <?php // Discover what 8am in Tokyo relates to on the East Coast of the US // Set the default timezone to Tokyo time: date_default_timezone_set(‘Asia/Tokyo’); // Now generate the timestamp for that particular timezone, on Jan 1st, 2000 $stamp = mktime(8, 0, 0, 1, 1, 2000); // Now set the timezone back to US/Eastern date_default_timezone_set(‘US/Eastern’); …

Continue Reading

if Statement Uses else

if Statement uses else When working with the if statement, you will often want to define an alternative block of code that should be executed if the expression you are testing evaluates to false. You can do this by adding else to the if statement followed by a further block of code: if ( expression ) { // code to …

Continue Reading

if Statement in php

if Statement in php An if statement is a way of controlling the execution of a statement that follows it (that is, a single statement or a block of code inside braces). The if statement evaluates an expression between parentheses. If this expression results in a true value, the statement is executed. Otherwise, the statement is skipped entirely. This enables …

Continue Reading

PHP Date() Function

date-> Format a local time/date. date(format,timestamp) format            : Required. Specifies the format of the timestamp timestamp     : Optional. Specifies a timestamp. Default is the current date and time The following characters are recognized in the format parameter string format character Description Example returned values Day — — d Day of the month, 2 digits …

Continue Reading

What is str_split?

str_split : Convert a string to an array <?php $str = “Anwar Hossain”; $arr1 = str_split($str); $arr2 = str_split($str, 3); print_r($arr1); print_r($arr2); ?> OUTPUT: Array ( 0 => A 1 => n 2 => w 3 => a 4 => r 5 => 6 => H 7 => o 8 => s 9 => s 10 => a 11 => …

Continue Reading

Regx validation in Zend Framework

Regx validation in Zend Framework Here showing Email validation.  $email = new Zend_Form_Element_Text(’email_address’); $email->setLabel(‘Email Address:’) ->addValidators( array( array(‘regex’, false, array(‘pattern’ => ‘/^.+@.+..{2,}$/i’)))) ->setRequired(true) ->setAttribs(array(‘id’ => ’email_address’, ‘class’ => ‘input-text-field’)) ->addErrorMessage(‘please enter a valid email address’);

Continue Reading