$array = array(3, 5, 2, 8);
Applicable sort functions:
sort
rsort
asort
arsort
natsort
natcasesort
ksort
krsort
$array = array(3, 5, 2, 8);
Applicable sort functions:
sort
rsort
asort
arsort
natsort
natcasesort
ksort
krsort
$string = file_get_contents("/home/test.json"); $json_a = json_decode($string, true); foreach ($json_a as $person_name => $person_a) { echo $person_a['status']; }
$xml = simplexml_load_string($xml_string); $json = json_encode($xml); $array = json_decode($json,TRUE);
No output before sending headers!
Functions that send/modify HTTP headers must be invoked before any output is made. summary ⇊ Otherwise the call fails:
Warning: Cannot modify header information – headers already sent (output started at script:line)
Some functions modifying the HTTP header are:
header / header_remove
session_start / session_regenerate_id
setcookie / setrawcookie
Output can be:
Unintentional:
Whitespace before
The UTF-8 Byte Order Mark specifically
Previous error messages or notices
Intentional:
print, echo and other functions producing output
Raw sections prior <?php code.
Having this:
$unsafe_variable = $_POST['user_input']; mysql_query("INSERT INTO `table` (`column`) VALUES ('$unsafe_variable')");
You have to do this:
$stmt = $dbConnection->prepare('SELECT * FROM employees WHERE name = ?'); $stmt->bind_param('s', $name); // 's' specifies the variable type => 'string' $stmt->execute(); $result = $stmt->get_result(); while ($row = $result->fetch_assoc()) { // do something with $row }
$a = 'How are you?'; if (strpos($a, 'are') !== false) { echo 'true'; }
PLANTILLA SUMA CANTIDADES DE FACTURAS AUTÓNOMOS CON IVA E IRPF
Descargar aquí:
Plantilla para hacer un seguimiento de tus gastos personales, lleva tus finanzas de la mejor manera, como recomiendan los profesionales de la economía y temas financieros. Para conocer bien tus gastos debes llevar un seguimiento y que mejor manera que con esta plantilla de Excel o Libreoffice.
Descargar aquí:
Plantilla para Excel con el Calendario por meses de los años 2018 y 2019. Para que lo tengas siempre a mano este calendario en tu ordenador y lo puedas abrir con Microsoft Excel o LibreOffice.
Descargar aquí:
Plantilla para tener tu lista de contactos y apuntar los correos, los teléfonos, la empresa a la que trabajan e incluso su Facebook. Más profesional que apuntar información en tu móvil y luego olvidar dónde la guardaste.
Descargar aquí: