This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $time = array('morning', 'noon'); | |
| array_filter($time, function($a){ | |
| if($a=='noon') | |
| echo 'Its lunch time'; | |
| else | |
| echo "Its time for breakfast"; | |
| } | |
| ); | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $data = array ('name' => 'hello', 'email' => 'hello@hello.com'); | |
| $data = http_build_query($data); | |
| $context_options = array ( | |
| 'http' => array ( | |
| 'method' => 'POST', | |
| 'header'=> "Content-type: application/x-www-form-urlencoded\r\n" | |
| . "Content-Length: " . strlen($data) . "\r\n", | |
| 'content' => $data | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| echo "<pre>"; | |
| print_r(array_reverse(debug_backtrace(true))); | |
| echo "</pre>"; | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Application class | |
| * | |
| * @author Shameer | |
| */ | |
| class Application { | |
| private $plugins = array(); | |
| public function __construct() { | |
| // Constructor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // This function uses simple filter_var function | |
| // instead of regular expression to validate email | |
| // @param string email Email address to be validated | |
| function validateEmail($email) { | |
| return filter_var($email, FILTER_VALIDATE_EMAIL); | |
| } | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| div.example { | |
| width: 300px; /* applied in all browsers */ | |
| *width: 350px; /* applied to IE6 and IE7 only */ | |
| _width: 360px; /* applied to IE6 only */ | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $sum = function($a,$b){ | |
| return $a+$b; | |
| }; | |
| echo $sum(2,5); | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <? | |
| $dsn = 'mysql:dbname=test;host=hostname'; | |
| $user = 'username'; | |
| $password = 'Password'; | |
| try { | |
| $dbh = new PDO($dsn, $user, $password); | |
| echo "Connected"; | |
| } catch (PDOException $e) { | |
| echo 'Connection failed: ' . $e->getMessage(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Use the fourth argument as false | |
| echo htmlentities($foo, ENT_COMPAT, 'UTF-8',false); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if(navigator.appName=="Microsoft Internet Explorer" ) { | |
| return false; | |
| } | |
| else { | |
| return this.init(canvasId,displayRadius,skinId,showSecondHand,gmtOffset); | |
| } |