This file contains 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 | |
function sum($a, $b): float { | |
return $a + $b; | |
} | |
// Note that a float will be returned. | |
var_dump(sum(1, 2)); | |
?> |
This file contains 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
server | |
{ | |
server_name mysite.com; #first domain | |
root /var/www/html; | |
index index.php index.html index.htm; | |
error_page 404 /404.html; | |
location / | |
{ | |
try_files $uri $uri/ /index.php?q=$uri&$args; # this rewrite rule is for wordpress blog | |
} |
This file contains 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
listen = 127.0.0.1:9000 | |
;listen = /var/run/php-fpm/php-fpm.sock #uncomment this if you want to use socket instead of port | |
;listen.owner = nobody | |
listen.owner = nginx | |
;listen.group = nobody | |
listen.group = nginx | |
;listen.mode = 0666 | |
listen.mode = 0664 | |
user = nginx | |
group = nginx |
This file contains 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
server | |
{ | |
root /var/www/html; | |
location / | |
{ | |
index index.php index.html index.htm; | |
} | |
location ~ \.php$ | |
{ | |
fastcgi_pass 127.0.0.0.1:9000 |
This file contains 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
/* | |
* Write a function that will return the | |
* count of distinct case-insensitive alphabetic | |
* characters that occur more than once in the | |
* given string. The given string can be | |
* assumed to contain only uppercase and | |
* lowercase alphabets. | |
* | |
* @Input: a string | |
* @Output: the number of unique characters that appear more than once |
This file contains 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 | |
$polynomial = array (1,1,0,1); // x^3+x+1 | |
$derivative = array(); | |
for ($i = 1 ; $i < count($polynomial); $i++ ) | |
{ | |
$derivate = $i * $polynomial[$i]; | |
$index = $i - 1; | |
if ( $index > -1 ) | |
{ | |
$derivative[$index] = $derivate; |
This file contains 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 | |
/* simplest Polymorphism example in Php */ | |
abstract class Animal | |
{ | |
static function makeSound(Animal $animal) | |
{ | |
return $animal->getsound(); | |
} | |
} | |
This file contains 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 | |
class Mysingleton | |
{ | |
private static $instance; | |
private function __construct() | |
{} | |
public static function getInstance() | |
{ | |
if ( self::$instance == NULL ) |