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 | |
//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. |
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 | |
// 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++){ |
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 | |
$str = "abcde"; | |
$a=str_split($str,2); | |
$nb = count($a); | |
if(strlen($a[$nb-1])<2) $a[$nb-1].="_"; | |
var_dump($a); | |
?> |
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 | |
include("config.php"); | |
session_start(); | |
$error=''; | |
// $_SESSION['testcomplete'] = 'yes'; | |
if($_SERVER["REQUEST_METHOD"] == "POST") { |
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 | |
// 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 |
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 | |
$rows = ''; $attr = 'class="table"';$rn = PHP_EOL; | |
for($i=0; $i<10;$i++) | |
{$rows .= '<tr>'.$rn; | |
for($j=0; $j<10;$j++) | |
$rows .= sprintf("\t\t".'<t%1$s>'.$i.'.'.$j.'</t%1$s>'.$rn, (($i==0||$j==0)?'h':'d')); | |
$rows .= '</tr>'.$rn; } | |
echo $table = sprintf('<table %s>%s</table>',$attr, $rows ) | |
?> | |
<style>.table, .table tr, .table td {border-collapse:collapse; border:1px solid black;} .table td, .table, th{padding:3px;}</style> |
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 | |
function stray($arr) | |
{ | |
$arr = array_count_values($arr); | |
foreach($arr as $key => $value){ | |
if($value===1)return $key; | |
} | |
} | |
var_dump(stray([1,2,1,1])); |
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 | |
header('content-type: text/plain'); | |
$data = '1000$ | |
Lorem ipsum dolor sit amet, | |
consectetur adipiscing elit, sed do eiusmod tempor incididunt.$ | |
1001$ | |
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.$'; |
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 | |
$n = 6; | |
$teller = 1; | |
for($i = 1; $i < $n; $i++) { | |
$teller = $teller * $i; | |
echo"$teller <br>"; | |
} | |
echo"5 faculteit is $teller <br>"; | |
?> |
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 | |
?> |