Skip to content

Instantly share code, notes, and snippets.

@phpfiddle
phpfiddle / fiddle_024187.php
Created April 21, 2019 09:55
[ Posted by Phpsitescripts@outlook.com ] Basic example of polymorphism in PHP.
<?php
abstract class User {
protected $scores = 0;
protected $numberOfArticles = 0;
public function setNumberOfArticles($int) {
$numbeOfArticles = (int)$int;
$this->numberOfArticles = $numbeOfArticles;
}
public function getNumberOfArticles() {
return $this->numberOfArticles;
@phpfiddle
phpfiddle / fiddle_094030.php
Created April 21, 2019 09:50
[ Posted by Phpsitescripts@outlook.com ] PHP interfaces and abstract classes example.
<?php
class User {
protected $username;
public function setUsername($uname) {
$this->username = $uname;
}
public function getUsername() {
return $this->username;
}
}
@phpfiddle
phpfiddle / fiddle_045666.php
Created April 21, 2019 07:04
[ Posted by Phpsitescripts@outlook.com ] Example of simple PHP abstract class and method.
<?php
abstract class User {
protected $username;
public function setUsername($uname) {
$this->username = $uname;
}
public function getUsername() {
return $this->username;
}
abstract public function stateYourRole();
@phpfiddle
phpfiddle / fiddle_084583.php
Created April 21, 2019 06:50
[ Posted by Phpsitescripts@outlook.com ] Simple example of PHP inheritance and accessing private properties.
<?php
// simple inheritance and modifiers example.
class User {
private $username;
public function setUsername($uname) {
$this->username = $uname;
}
public function getUsername() {
return $this->username;
}
@phpfiddle
phpfiddle / fiddle_088519.php
Last active March 28, 2019 00:57
[ Posted by Shokeen Menaria ] UserDetail
This gist was removed completely.
@phpfiddle
phpfiddle / fiddle_060071.php
Created March 21, 2019 00:00
[ Posted by Ryan ] main css file
h1 {
text-align: center;
}
@phpfiddle
phpfiddle / fiddle_022619.php
Created March 19, 2019 14:51
[ Posted by Iva ] Check IP contains into range
<?php
/*
* ip_in_range.php - Function to determine if an IP is located in a
* specific range as specified via several alternative
* formats.
*
* Network ranges can be specified as:
* 1. Wildcard format: 1.2.3.*
* 2. CIDR format: 1.2.3/24 OR 1.2.3.4/255.255.255.0
* 3. Start-End IP format: 1.2.3.0-1.2.3.255
@phpfiddle
phpfiddle / fiddle_070966.php
Created March 19, 2019 13:22
[ Posted by Ayestes ] Sample Interview Questions
<?php
/**
* Live Coding Section
* - You don't need to finish all of this.
* - Using the internet to look things up is encouraged.
*/
echo 'Live Coding Section starts here! <br/><br/>';
// Write three functions that compute the sum of the numbers in a given list using: a for-loop, a while-loop, and then recursion.
@phpfiddle
phpfiddle / fiddle_047558.php
Created March 18, 2019 13:16
[ Posted by Sheri ] Merge, Concatenante and Override Array
<?php
$data[] = [
'sponsor_id' => 2,
'enroller_id' => 4,
];
//using [] after $data will concatenate otherwise override
$data[] = [
'sponsor_id4' => 2,
'enroller_id5' => 4,
@phpfiddle
phpfiddle / fiddle_087985.php
Created March 7, 2019 14:43
[ Posted by Christosl ] php-converting-mcrypt-to-openssl
<pre>
<?php
$key = md5(utf8_encode("MobileAppSecureKey"), true);
$data = base64_decode("bkCfcseIt/TPsgNCdyX9fv2/4MjOJdaPXakNNbxQT3n6tXHa5bDoXojQ3g7jPLCu+wjwD0guQzw3hCFUSVx47PmDNHASk7g/kJ4K4tX0VGI=");
for($i = 0; $i < 8; $i++) {
$key[$i + 16] = $key[$i];
}