Skip to content

Instantly share code, notes, and snippets.

@phpfiddle
phpfiddle / fiddle_062244.php
Created November 11, 2020 10:32
[ Posted by Itw Team ] php static vs self method
<?php
class House {
public static function label() {
return "House";
}
public function getChildLabel() {
return static::label();
}
@phpfiddle
phpfiddle / fiddle_020347.php
Created November 6, 2020 02:24
[ Posted by Arizan Misbah ] php learning register
<?php
require_once "dbcon.php";
$json = file_get_contents('php://input');
$obj = json_decode($json, true);
$username = $obj['username'];
$password = $obj['password'];
$email = $obj['email'];
@phpfiddle
phpfiddle / fiddle_083546.php
Created November 2, 2020 22:18
[ Posted by Amar Beslija ] How to use white lists in PHP. https://lab387.com
<html>
<head>
<title>White List</title>
<meta charset="utf-8">
</head>
<body>
<form action="" method="POST">
<label>Choose your color:</label>
<select name="color">
@phpfiddle
phpfiddle / fiddle_038259.php
Created November 2, 2020 22:16
[ Posted by Amar Beslija ] How to use black lists. https://lab387.com
<html>
<head>
<title>Black List</title>
<meta charset="utf-8">
</head>
<body>
<form action="" method="POST">
<label>Choose your color:</label>
<select name="color">
@phpfiddle
phpfiddle / fiddle_019123.php
Created November 2, 2020 22:10
[ Posted by Amar Beslija ] How to show PHP code inside HTML page for showcases or examples. https://lab387.com
<?php
/* If we want to show some PHP code inside HTML page for showcase, example, etc., here is the way to do it */
// Code we want to show inside HTML page
$code = '
<?php
echo "Test code to be output with everything else";
?>';
@phpfiddle
phpfiddle / fiddle_015787.php
Created August 27, 2020 19:23
[ Posted by Mitch ] Mitchell_Laurie_Assign1.php
<?php
$MyFirstVariable = 'Mitchell'; //making of my first variable
$Mitchell = '$MyFirstVariable';
echo "My first variable was named " , $Mitchell , "."; //Outputs My first variable was named $MyFirstVariable.
echo " The value of my variable was " , $MyFirstVariable , "."; //Outputs The value of my variable was Mitchell.
$empty = array(); //creates empty array
$array = array('Mitchell' , 'Laurie' , 'Fall semester 2020'); //creates an array with my firstname, lastname, and semester
@phpfiddle
phpfiddle / fiddle_018277.php
Created August 20, 2020 11:20
[ Posted by Majid ] Updated the php code
<?php
$x=5;
$y=6;
$a=1;
@phpfiddle
phpfiddle / fiddle_073001.php
Created August 17, 2020 22:00
[ Posted by Sohaib Karim ] PHP 1D And 2D Array in Table Format
<?php
$movies = array(
array('Bad Boys For Life' , 'Comedy' , 'Mike Judge' ),
array('To Little' , 'Action' , 'Andy / Larry Wachowski' ),
array('Jumanji The Next Level' , 'Comedy / Adventure' , 'Sofia Coppola' ),
array('IP Man 4' , 'Action' , 'Ron Howard' ),
array('SpiderMan Far From Home' , 'Adventure' , 'Jared Hess' )
);
echo '<table border="1">';
@phpfiddle
phpfiddle / fiddle_067521.php
Created August 17, 2020 17:29
[ Posted by Muhammad Sadiq 2849028 ] Php Array assignment
<!DOCTYPE html>
<html>
<head>
<title>Php Assignment</title>
<style type="text/css">
.tblstyl{
color: yellow;
background-color: purple;
width: 100px;
text-align: center;
@phpfiddle
phpfiddle / fiddle_047807.php
Created August 14, 2020 04:27
[ Posted by Ricky Aditya ] Count positive numbers or sum negative numbers
<?php
function countPositivesSumNegatives(array $numbers) {
$result = array();
$total = 0;
$i = 0;
if (!empty($numbers)) {
foreach($numbers as $number) {
if($number < 0) {
$total += $number;