note 130105 added to function.require-once
| From: | toni@nexbit.ca | Date: | Sat, 01 Mar 2025 13:13:53 +0000 |
| Subject: | note 130105 added to function.require-once | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221931@lists.php.net to get a copy of this message | ||
Rouler du javascript sur mdn: developer.mozilla.org/play
demander un input: prompt("text);
convertir en entier: parseInt();
attention: symbole d'exposant = **
obtenir par id: getElementById
obtenir par type: getElementByTagName
obtenir par classe: getElementByClassName
// éxécuter afficherMsg() lorsque le bouton avec id button est click:
document.querySelector("#button").addEventListener("click", afficherMsg);
modifier un attribut: document.getElementById(id).setAttribute(nom, valeur);
modifier le style d'un élément: element.style.backgroundColor = "pink";
modifier les classes d'un élémentt: element.classList.add(nouvelleClasse);
créer un élément: let element = document.createElement("div");
enfantir un élément: element.appendChild(childElement);
événement avec JQuery: $("#btn").click(function(){ $("p")[0].innerHTML +=
"allo"; });
fonction fléchée: const calculerSommer2 = (a, b) => { return a+b };
créer des éléments avec JQuery: const element = $("<div></div>");
Tableaux JS: [el1, el2, el3...]
modifier le CSS d'un élément: element.css(propriété, valeur);
PHP
balise php: <?php ?>
pour créer une constante: define(nom, valeur) ;
Saisir une string au clavier: $e = fgets(STDIN);
convertions de types:
- intval($str);
- strval($nbr);
- floatval($str);
- doubleval($str);
- boolval($str);
Grandeur d'une liste en php: count()
Tableaux associattifs: $tab = [$cle1 => $valeur1, $cle2...];
loop liste: foreach ($tab as $val) {}
concaténation: "."
require_once 'header.php';
vérifier si une variable est un nombre: is_numeric()
JSON:
JavaScript:
JSON.stringify(obj) = convertir de objet JS Ã JSON
JSON.parse(json) = convertir de JSON Ã objet JS
php:
json_encode(tab_associatif) = convertir de tableau associatif à JSON
json_decode(json, true) = convertir de chaine JSON Ã tableau associatif
// extraire une chaine JSON du corps de la requête:
$contenu = file_get_contents("php://input");
continue; // passer à la prochaine itération de la boucle
break; // sortir de la boucle
$tab.includes('element); // tester si un tableau contient un élément
'maChaine'.substring(1, 4) // extraire une partie de chaine
toUpperCase()
// exemple fetch JavaScript:
let resultat await fetch('...');
let resultatJSON = await resultat.json();
Math.round(2.5) // arrondis
Math.random() // génère un nombre entre 0 et 1
'ballon rouge'.replace('rouge', 'vert') // replacer une partie de
string en JS
exemple expression ternaire: let resultat = a > b ? 'a est plus grand' : 'b est
plus grand';
exemple foreach: monTableau.forEach(element => { /* code / });
exemple fonction fléchée: let foo = (x) => { return x x; };
----
Server IP: 45.112.84.4
Probable Submitter: 45.112.84.18 (proxied: 208.94.104.38)
----
Manual Page -- https://php.net/manual/en/function.require-once.php
Edit -- https://main.php.net/note/edit/130105
Del: integrated -- https://main.php.net/note/delete/130105/integrated
Del: useless -- https://main.php.net/note/delete/130105/useless
Del: bad code -- https://main.php.net/note/delete/130105/bad+code
Del: spam -- https://main.php.net/note/delete/130105/spam
Del: non-english -- https://main.php.net/note/delete/130105/non-english
Del: in docs -- https://main.php.net/note/delete/130105/in+docs
Del: other reasons-- https://main.php.net/note/delete/130105
Reject -- https://main.php.net/note/reject/130105
Search -- https://main.php.net/manage/user-notes.php