TutoBlog

6 noviembre 2018

Sort arrays in PHP

Filed under: General — joan16v @ 12:20
$array = array(3, 5, 2, 8);

Applicable sort functions:

sort
rsort
asort
arsort
natsort
natcasesort
ksort
krsort

Parse JSON with PHP

Filed under: General — joan16v @ 12:18
$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'];
}

Parse XML in PHP

Filed under: General — joan16v @ 12:16
$xml = simplexml_load_string($xml_string);
$json = json_encode($xml);
$array = json_decode($json,TRUE);

Fix Headers already sent error in PHP

Filed under: General — joan16v @ 12:14

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.

Stackoverflow

Prevent SQL injection in PHP

Filed under: General — joan16v @ 12:11

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
}

Check if a string contains a specific word in PHP

Filed under: General — joan16v @ 12:09
$a = 'How are you?';

if (strpos($a, 'are') !== false) {
    echo 'true';
}

19 octubre 2018

PLANTILLA SUMA CANTIDADES DE FACTURAS AUTÓNOMOS CON IVA E IRPF

Filed under: General — joan16v @ 11:48

PLANTILLA SUMA CANTIDADES DE FACTURAS AUTÓNOMOS CON IVA E IRPF

Descargar aquí:

http://infopade.com/5JqZ

Plantilla Excel de gastos personales y finanzas

Filed under: General — joan16v @ 8:24

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í:

http://infopade.com/5Auh

Plantilla para Excel – Calendario 2018 2019

Filed under: General — joan16v @ 7:37

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í:

http://infopade.com/58xz

Plantilla de Excel de Lista de Contactos

Filed under: General — joan16v @ 7:15

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í:

http://infopade.com/582T

Página siguiente »

Crea un blog o un sitio web gratuitos con WordPress.com.