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 […]
Read Moreif 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 […]
Read Moredate-> 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 […]
Read Morestr_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 […]
Read MoreRegx 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’);
Read Moresubstr() This function returns a part of a string. substr(string,start,length) string : The input string. Must be one character or longer. start : The start is how many characters in to skip before starting. Setting this to 3 would skip the first three and start returning at the forth character. Setting this to a negative […]
Read Moresplit()-used for JavaScript for processing the string and the explode()-used to convert the String to Array, implode()-used for convert the array to String. split() can work using regular expressions.but Explode use only single value to explode string into Array Here the Example <?php $date = “04/30/1973″; list($month, $day, $year) = split(‘[/.-]’, $date); ?> ……………………………………………………………………… <?php […]
Read Morehtmlspecialchars: Convert special characters to HTML entities. htmlentities: Convert all applicable characters to HTML entities. htmlspecialchars only takes care of <, >, single quote ‘, double quote ” and ampersand. htmlentities translates all occurrences of character sequences that have different meaning in HTML. <?php $str = “A ‘quote’ is <b>bold</b>”; echo htmlentities($str); echo htmlentities($str, ENT_QUOTES); […]
Read MoreJust copy the below code and run from your local server. <html> <head> <title>Hello World</title> <body> <?php echo “hello, world”;?> </body> </html> output: hello, world
Read MoreWhat is PHP? Devised by Rasmus Lerdorf in 1994,PHP is a programming language that allows building dynamic, interactive websites. PHP stands for PHP: Hypertext Preprocessor.PHP is a server-side scripting language.PHP scripts are executed on the server.PHP supports many databases like MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC. PHP is open source software. PHP is […]
Read More