Category: php

[PHP] Ritornare un codice di stato HTTP

Nel tutorial di oggi imparerete come creare una funzione PHP che prende in ingresso il codice di risposta HTTP e ne restituisce la descrizione.

 
function getStatusCodeMessage($status){
// these could be stored in a .ini file and loaded
// via parse_ini_file()... however, this will suffice
// for an example
$codes = Array(
100  => 'Continue',
101  => 'Switching Protocols',
200  => 'OK',
201  => 'Created',
202  => 'Accepted',
203  => 'Non-Authoritative Information',
204  => 'No Content',
205  => 'Reset Content',
206  => 'Partial Content',
300  => 'Multiple Choices',
301  => 'Moved Permanently',
302  => …

Creare un semplice CAPTCHA con PHP

[PHP - Magento] Controllare se un determinato cliente è loggato o meno

Come utilizzare la funzione array_column di PHP 5.5

[PHP - WordPress] Creare uno short code “Seguimi su Twitter”

Creare una funzione in_array ricorsiva con PHP

Come creare un sistema di votazione in stile YouTube con jQuery e PHP

[PHP] Come rilevare se un utente sta visualizzando il sito con un dispositivo Android

In questo semplice tutorial PHP vi mostreremo come creare una funzione che rileva se l’utente che sta visitando il vostro sito sta utilizzando un dispositivo Android.

 
function isItAndroid()
{
	$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
	if(stripos($ua,'android') !== false) return true;
	else return false;
}
 …

Come linkare automaticamente un username Twitter con PHP

Nel tutorial PHP di oggi vi mostreremo come creare una funzione che crea automaticamente un link se trova all’interno di un testo una username Twitter.

 
function twtreplace($content) {
	$twtreplace = preg_replace('/([^a-zA-Z0-9-_&])@([0-9a-zA-Z_]+)/',"$1<a href=\"http://twitter.com/$2\" target=\"_blank\" rel=\"nofollow\">@$2</a>",$content);
	return $twtreplace;
}
 

Se volete applicare questa funzione su un blog WordPress, incollate il seguente codice all’interno del file functions.php del vostro tema WordPress.

 
function twtreplace($content) {
	$twtreplace = preg_replace('/([^a-zA-Z0-9-_&])@([0-9a-zA-Z_]+)/',"$1<a href=\"http://twitter.com/$2\" target=\"_blank\" rel=\"nofollow\">@$2</a>",…

PHPSESSID nelle tue URL? Impara come redirezionarle con il 301 di PHP!

[PHP - Magento] Controllare se un particolare cliente è loggato o meno

Condividi





Booking online




Categorie