View fiddle_058813.php
<?php
function getimg($sizeindex, $imgname ){
$imgsizes = array(
'x1267'=>'This is size 0 ' . $imgname ,
'x1268'=>'this is size 1 '. $imgname,
'x1269'=>'this is size two '. $imgname,
'x1210'=>'this is size three '. $imgname,
);
echo "My favorite number is " . $imgsizes[$sizeindex];
View fiddle_040668.php
<?php
//this is a single comment
#this is also a single line comment
/*this is a multiple
line comment
*/
//PHP statement end with a semicolon
View fiddle_079137.php
<?php
echo 'Hello world';
?>
View fiddle_096610.php
<?php
echo 'sample code';
?>
View fiddle_019884.php
<?php
echo 'Hello World';
?>
View fiddle_023131.php
<?php
//Autor: Walter Sanchez
//Fecha: 02 abril 2018
class html{
private $script=null;
public function cabeza($tituloPagina="Sin Titulo"){
$inicio = '<!DOCTYPE html> <html lang="es"> <head> <meta charset="UTF-8"> <title>'.$tituloPagina.'</title>';
$cierreHead = '</head>';
// compruebo que la propiedad script no sea nula es decir que se haya seteado.
View fiddle_033139.php
<?php
// Simple Encryption #1 - Alternating Split
/*
For building the encrypted string:
Take every 2nd char from the string, then the other chars, that are not every 2nd char, and concat them as new String.
Do this n times!
*/
function encrypt($text, $n) {
for($i=0;$i<$n;$i++){
View fiddle_029304.php
<?php
$str = "abcde";
$a=str_split($str,2);
$nb = count($a);
if(strlen($a[$nb-1])<2) $a[$nb-1].="_";
var_dump($a);
?>
View fiddle_080222.php
<?php
include("config.php");
session_start();
$error='';
// $_SESSION['testcomplete'] = 'yes';
if($_SERVER["REQUEST_METHOD"] == "POST") {
View fiddle_026210.php
<?php
// Multiples of 3 or 5 PHP
// If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
// Finish the solution so that it returns the sum of all the multiples of 3 or 5 below the number passed in.
function solution($number) {
$tot = 0;
for ($i = 3; $i < $number; $i++) if ($i % 3 === 0 || $i % 5 === 0) $tot += $i;
return $tot;
}
echo solution(10);//23