Chi sviluppa ha sempre in riserva un set di funzioni e script al quale difficilmente rinuncerebbe. Oggi condivido le mie, personali funzioni coadiuvate da altre, le migliori in circolazione sul web (citando la fonte). Troverete tra le più disparate, tanto per fare un esempio: integrazione con le api dei social network e dei servizi web (Gravatar, Twitter, ecc…), date e conversioni, stringhe, calendari e molto altro ancora. Buon divertimento!
1. Detect user agent
Funzione di detect, ottima per verificare, ad esempio nel settore mobile se lo user agent è un ipad, iphone, android e chi più ne ha più ne metta. Restituisce true o false.
function detect($str){
return strstr($_SERVER['HTTP_USER_AGENT'], $str);
}
Utilizzo:
echo detect('iPad');
echo detect('iPhone');
echo detect('BlackBerry');
2. Conversione fra due valute
function currency($from_Currency,$to_Currency,$amount) {
$amount = urlencode($amount);
$from_Currency = urlencode($from_Currency);
$to_Currency = urlencode($to_Currency);
$url = "http://www.google.com/ig/calculator?hl=en&q=$amount$from_Currency=?$to_Currency";
$ch = curl_init();
$timeout = 0;
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT , "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)");
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$rawdata = curl_exec($ch);
curl_close($ch);
$data = explode('"', $rawdata);
$data = explode(' ', $data['3']);
$var = $data['0'];
return round($var,2);
}
Utilizzo:
echo currency("USD","EUR",100);
Fonte: http://www.phpsnippets.info/convert-currencies-using-php-google-and-curl
3. Ridimensionamento proporzionale immagine
Questa funzione ridimensiona in visuale un’immagine partendo dalla larghezza mantenendo le proporzioni in altezza, ha come ingresso due parametri (percorso fisico dell’immagine e larghezza massima della stessa in pixel):
function scale_image($foto, $maxdim){
$thumb_width = $maxdim;
list($fullsize_width, $fullsize_height) = getimagesize($foto);
$thumb_height = @floor($fullsize_height/($fullsize_width/$thumb_width));
if($fullsize_width > $thumb_width){ $width = $thumb_width; $height = $thumb_height; } else { $width = $fullsize_width; $height = $fullsize_height; }
return '
';
}
Utilizzo:
echo scale_image('images/immagine.jpg', '500');
4. Calcolo dell’iva
Semplicissima funzione per il calcolo dell’iva
function iva($prezzo) {
$iva = 21; //definire costante dell'iva (21%)
$totale = $prezzo + (($prezzo / 100) * $iva);
$totale = round($totale, 2);
return $totale;
}
Utilizzo:
echo iva('1000'); //restituirà il prezzo compreso d'iva (1210)
5. Verifica presenza caratteri speciali in una stringa
function check_char($string){
if (ereg('[^A-Za-z0-9]', $string))
echo "La stringa contiene caratteri speciali";
else
echo "La stringa non contiene caratteri speciali";
}
Utilizzo:
check_char('stringa_alfanumerica21457'); //restituirà il rispettivo messaggio
6. Mostrare contenuto di una directory
Fornire in input il nome della cartella e troverete in output il suo contenuto
function directory_list($path){
$dir_handle = @opendir($path) or die("Impossibile aprire $path");
while ($file = readdir($dir_handle)){
if($file == "." || $file == ".." || $file == "index.php" )
continue;
echo $file . '
';
}
closedir($dir_handle);
}
directory_list('immagini/');
7. Cerca una serie di parole in una stringa
hilight vuole in ingresso due parametri: la stringa e un array con le parole da evidenziare all’interno del testo.
function highlight($sString, $aWords) {
if (!is_array ($aWords) || empty ($aWords) || !is_string ($sString)){
return false;
}
$sWords = implode ('|', $aWords);
return preg_replace ('@\b('.$sWords.')\b@si', '$1', $sString);
}
Utilizzo:
echo highlight('Lorem Ipsum è un testo segnaposto utilizzato nel settore della stampa.', array ('Lorem', 'testo', 'settore'));
Fonte: http://www.phpsnippets.info/highlights-words-in-a-phrase
8. Rimozione ultimo carattere
Rimuove l’ultimo carattere all’interno di una stringa può essere utile quando si generano dinamicamente elementi con un separatore, ad esempio se all’interno di questa stringa (“mario, paolo, pasquale, nicola,”) volessi eliminare l’ultima virgola a partendo dalla fine utilizzerò la funzione:
function removes($string, $marker) {
if (substr($string, -1) == $marker) {
return substr($string, 0, -1);
}
return $string;
}
Utilizzo:
$stringa = "mario, paolo, pasquale, nicola,";
echo removes($stringa, ',');
9. Ottenere numero di Twitter follower
Ottima funzione PHP che dato in input un twitter id restituisce il numero di follower.
function get_followers($twitter_id){
$xml=file_get_contents('http://twitter.com/users/show.xml?screen_name='.$twitter_id);
if (preg_match('/followers_count>(.*)',$xml,$match)!=0) {
$tw['count'] = $match[1];
}
return $tw['count'];
}
Utilizzo:
echo get_followers('twitter_id');
10. Visualizzare gli ultimi tweet
Twitter ha cambiato le proprie API. Potete visualizzare il nuovo funzionamento presso questo link:
Visualizzare gli ultimi tweet sul sito con le nuove api oAuth
Attraverso le API di Twitter ecco una funzione che permette di postare gli ultimi tweet da un account con PHP. Essendo molto lunga risparmio qualche riga e vi rimando direttamente alla fonte da cui l'ho attinta:
Utilizzo:
display_latest_tweets('YOUR_TWITTER_ID');
11. Conteggio numero Tweet con Php
Rimanendo in tema Twitter un'utile funzione che permette di conteggiare il numero di retweet di un URL in ingresso:
function tweetCount($url) {
$content = file_get_contents("http://api.tweetmeme.com/url_info?url=".$url);
$element = new SimpleXmlElement($content);
$retweets = $element->story->url_count;
if($retweets){
return $retweets;
} else {
return 0;
}
}
Utilizzo:
echo tweetCount('url_link');
12. Decomprimere file zip
function unzip($location,$newLocation){
if(exec("unzip $location",$arr)){
mkdir($newLocation);
for($i = 1;$i< count($arr);$i++){
$file = trim(preg_replace("~inflating: ~","",$arr[$i]));
copy($location.'/'.$file,$newLocation.'/'.$file);
unlink($location.'/'.$file);
}
return TRUE;
}else{
return FALSE;
}
}
Utilizzo:
if(unzip('zipedfiles/test.zip','unziped/myNewZip'))
echo 'Success!';
else
echo 'Error';
Fonte: http://phpsnips.com/snippet.php?id=47
13. Calcolo età
function birthday($birthday){
$age = strtotime($birthday);
if($age === FALSE){
return FALSE;
}
list($y1,$m1,$d1) = explode("-",date("Y-m-d",$age));
$now = strtotime("now");
list($y2,$m2,$d2) = explode("-",date("Y-m-d",$now));
$age = $y2 - $y1;
if($m2-$m1 < 0 || $d2-$d1 > 0)
$age--;
return $age;
}
Utilizzo:
echo birthday('1986-07-22');
Fonte: http://phpsnips.com/snippet.php?id=7
14. Applicare watermark su immagine
Questa funzione permette l'applicazione di un watermark su un'immagine.
function watermark($file, $watermark, $pos = null, $x = 0, $y = 0){
$details = getimagesize($file);
$wDetails = getimagesize($watermark);
if(!is_null($pos)){
switch($pos){
case TOP_LEFT:
$x = 0;
$y = 0;
break;
case TOP_RIGHT:
$x = $details[0] - $wDetails[0];
$y = 0;
break;
case BOTTOM_LEFT:
$x = 0;
$y = $details[1] - $wDetails[1];
break;
case BOTTOM_RIGHT:
$x = $details[0] - $wDetails[0];
$y = $details[1] - $wDetails[1];
break;
case CENTER:
$x = round(($details[0] - $wDetails[0])/2);
$y = round(($details[1] - $wDetails[1])/2);
break;
}
}
switch($details['mime']){
case 'image/jpeg':$im = imagecreatefromjpeg($file);break;
case 'image/gif':$im = imagecreatefromgif($file);break;
case 'image/png':$im = imagecreatefrompng($file);break;
}
switch($wDetails['mime']){
case 'image/jpeg':$newWater = imagecreatefromjpeg($watermark);break;
case 'image/gif':$newWater = imagecreatefromgif($watermark);$colorTransparent = imagecolortransparent($newWater);imagefill($newWater, 0, 0, $colorTransparent);imagecolortransparent($newWater, $colorTransparent);break;
case 'image/png':$newWater = imagecreatefrompng($watermark);imagealphablending($newWater, false);imagesavealpha($newWater,true);break;
}
imagecopyresampled($im, $newWater, $x, $y, 0, 0, $wDetails[0], $wDetails[1], $wDetails[0], $wDetails[1]);
// Output the image
switch($details['mime']){
case 'image/jpeg':header('Content-type: image/jpeg');imagejpeg($im);break;
case 'image/gif':header('Content-type: image/gif');imagegif($im);break;
case 'image/png':header('Content-type: image/png');imagepng($im);break;
}
// Free up memory
imagedestroy($im);
}
Utilizzo:
watermark('girl.jpg','watermark.png');
watermark('girl.jpg','watermark.png', BOTTOM_RIGHT);
watermark('girl.jpg','watermark.png', null, 150, 150);
Fonte: http://phpsnips.com/snippet.php?id=105
15. Convertire un URL in TinyURL
function tiny_convert($url) {
return file_get_contents("http://tinyurl.com/api-create.php?url=" . $url);
}
Utilizzo:
tiny_convert('tuo_url');
16. Ottenere estensione di un file
function getFileExtension($file){
$path_parts = pathinfo($file);
return $path_parts['extension'];
}
Utilizzo:
echo getFileExtension('file_path');
17. Forzare download File
Spesso documenti come pdf o immagini vengono gestide in visuale dal browser mentre ci aspettiamo che vengano scaricate. Con questo script forziamo il download di ogni tipo di file.
function force_download($file) {
if ((isset($file))&&(file_exists($file))) {
header("Content-length: ".filesize($file));
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $file . '"');
readfile("$file");
} else {
echo "No file selected";
}
}
Utilizzo:
force_download('file_path');
18. Formato data "minuti, ore, giorni fa"
La Facebook mania potrebbe portarvi a sfruttare questo pezzetto di codice per ottenere un formato data del tipo "2 secondi fa".
function timeAgo($timestamp, $granularity=2, $format='Y-m-d H:i:s'){
$difference = time() - $timestamp;
if($difference < 0) return '0 secondi fa';
elseif($difference < 864000){
$periods = array('week' => 604800,'day' => 86400,'hr' => 3600,'min' => 60,'sec' => 1);
$output = '';
foreach($periods as $key => $value){
if($difference >= $value){
$time = round($difference / $value);
$difference %= $value;
$output .= ($output ? ' ' : '').$time.' ';
$output .= (($time > 1 && $key == 'day') ? $key.'s' : $key);
$granularity--;
}
if($granularity == 0) break;
}
return ($output ? $output : '0 secondi').' ago';
}
else return date($format, $timestamp);
}
Utilizzo:
$time = timeAgo($dateRef);
Fonte: http://www.phpsnippets.info/display-dates-as-time-ago
19. Utilizzare i Gravatar
Come per WordPress è possibile sfruttare i Gravatar anche per la tua applicazione PHP.
function show_gravatar($email) {
$email = trim($email);
$email = strtolower($email);
$email_hash = md5($email);
echo '
';
}
Utilizzo:
show_gravatar('email@gravatar.com');
20. Rimozione del www. all'interno della URL
Questa funzione rimuove il www. dalla URL
function www_remove(){
if(!strstr($_SERVER['HTTP_HOST'],'www.'))
return;
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://'.substr($_SERVER['HTTP_HOST'],4).$_SERVER['REQUEST_URI']);
exit();
}
Utilizzo:
www_remove();
21. Validazione Email
Snippet per la validazione di indirizzi Email attraverso le espressioni regolari..
function check_email($email){
if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email))
echo 'Indirizzo email corretto';
else
echo 'Indirizzo email non valido';
Utilizzo:
check_email('nome@dominio.it');
22. Abstract di un testo
La funzione "get_abstract" permette di restituire il riassunto di un testo al quale imputiamo un limite di caratteri (nell'esempio 200), essa non tronca sistematicamente all'ultimo carattere disponibile ma lo fa in maniera logica cercando di non compromettere l'integrità della parola.
function get_abstract( $string, $len ) {
if ( strlen($string) > $len ) {
$pos = ( $len - stripos(strrev(substr($string, 0, $len)), ' ') );
$sum = substr($string, 0, $pos-1);
$chr = $sum[strlen($sum)-1];
if ( strpos($chr, '.,!?;:') ) {
// STRIP LAST CHAR
$sum = substr($sum, 0, strlen($sum)-1);
}
// ADD ELLIPSIS
return $sum."…";
} else {
return $string;
}
}
Utilizzo:
$string = "Lorem Ipsum is simply dummy text of the printing and typesetting industry.";
echo get_abstract($string, 200);
Fonte: http://www.neilhillman.com/477/string-abstract-php-function.html
23. Generazione random di password
Generatore automatico di stringhe che può essere sfruttata come ottima soluzione per le password automatiche, di default a 7 caratteri.
function createRandomPassword() {
$chars = "abcdefghijkmnopqrstuvwxyz023456789";
srand((double)microtime()*1000000);
$i = 0;
$pass = '' ;
while ($i <= 7) {
$num = rand() % 33;
$tmp = substr($chars, $num, 1);
$pass = $pass . $tmp;
$i++;
}
return $pass;
}
// Usage
$password = createRandomPassword();
echo "Your random password is: $password";
Utilizzo:
echo createRandomPassword();
Fonte: http://www.totallyphp.co.uk/create-a-random-password
24. Paginazione con php/mysql
Ottima per effettuare paginazioni dinamiche utilizzando query MYSql.
function paging(){
global $num_rows;
global $page;
global $page_amount;
global $section;
if($page_amount != "0"){
echo "";
if($page != "0"){
$prev = $page-1;
echo "Prev";
}
for ( $counter = 0; $counter <= $page_amount; $counter += 1) {
echo "";
echo $counter+1;
echo "";
}
if($page < $page_amount){
$next = $page+1;
echo "Next";
}
echo "View All";
echo "";
}
}
// call on Pagination with function
Utilizzo
// paging code
// Query to count rows.
$result = mysql_query("SELECT * FROM Table_Name WHERE Column_Name = '$section'");
$items = 32; // number of items per page.
$all = $_GET['a'];
$num_rows = mysql_num_rows($result);
if($all == "all"){
$items = $num_rows;
}
$nrpage_amount = $num_rows/$items;
$page_amount = ceil($num_rows/$items);
$page_amount = $page_amount-1;
$page = mysql_real_escape_string($_GET['p']);
if($page < "1"){
$page = "0";
}
$p_num = $items*$page;
//end paging code
// Query that you would like to SHOW
$result = mysql_query("SELECT * FROM Table_Name WHERE Column_Name = '$section' ORDER BY 'name' ASC LIMIT $p_num , $items");
paging();
Fonte: http://snipplr.com/view.php?codeview&id=55519
25. Conversione da BBCode ad HTML
Passata una stringa come parametro decodifica le funzioni più comuni del BBCode ([b], [i], [u], ecc...) in HTML.
function bbcode($data)
{
$input = array(
'/\[b\](.*?)\[\/b\]/is',
'/\[i\](.*?)\[\/i\]/is',
'/\[u\](.*?)\[\/u\]/is',
'/\[img\](.*?)\[\/img\]/is',
'/\[url\](.*?)\[\/url\]/is',
'/\[url\=(.*?)\](.*?)\[\/url\]/is'
);
$output = array(
'$1',
'$1',
'$1',
'
',
'$1',
'$2'
);
$rtrn = preg_replace ($input, $output, $data);
return $rtrn;
}
Utilizzo:
echo bbcode('[b]Questo[/b] è un esempio di BBCODE');
Fonte: http://www.daniweb.com/web-development/php/code/303115
26. Conversione da JPG ad ASCII
Questo script converte un'immagine da formato JPG ad ASCII.
function getext($filename) {
$pos = strrpos($filename,'.');
$str = substr($filename, $pos);
return $str;
}
$image = 'image.jpg';
$ext = getext($image);
if($ext == ".jpg"){
$img = ImageCreateFromJpeg($image);
}
else{
echo'Wrong File Type';
}
$width = imagesx($img);
$height = imagesy($img);
for($h=0;$h<$height;$h++){
for($w=0;$w<=$width;$w++){
$rgb = ImageColorAt($img, $w, $h);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
if($w == $width){
echo '
';
}else{
echo '#';
}
}
}
Fonte: http://phpsnips.com/snippet.php?id=29
27. Generatore captcha in PHP
Sempre dalla fonte precedente ho trovato molto utile anche il generatore captcha, va implementato in 3 file:
- image.php - è il file core;
- form.html - è la pagina html nel quale va implementato il captcha;
- result.php - contiene il risultato
image.php
header("Content-type: image/png");
$string = "abcdefghijklmnopqrstuvwxyz0123456789";
for($i=0;$i<6;$i++){
$pos = rand(0,36);
$str .= $string{$pos};
}
$img_handle = ImageCreate (60, 20) or die ("Cannot Create image");
//Image size (x,y)
$back_color = ImageColorAllocate($img_handle, 255, 255, 255);
//Background color RBG
$txt_color = ImageColorAllocate($img_handle, 0, 0, 0);
//Text Color RBG
ImageString($img_handle, 31, 5, 0, $str, $txt_color);
Imagepng($img_handle);
session_start();
$_SESSION['img_number'] = $str;
form.html
<form action="result.php" method="post">
<img alt="Random Number" src="image.php">
<input type="text" name="num"><br>
<input type="submit" name="submit" value="Check">
</form>
result.php
session_start();
if($_SESSION['img_number'] != $_POST['num']){
echo'The number you entered doesn't match the image.
Try Again
';
}else{
echo'The numbers Match!
Try Again
';
}
Fonte: http://phpsnips.com/snippet.php?id=6
28. Ottenere la data di compleanno
Anche questa è un'ottima funzione per la stampa dell'età, nserendo in input un formato americano "yyyy-mm-dd" ottengo in output la rispettiva età.
function age($date){
$year_diff = '';
$time = strtotime($date);
if(FALSE === $time){
return '';
}
$date = date('Y-m-d', $time);
list($year,$month,$day) = explode("-",$date);
$year_diff = date("Y") – $year;
$month_diff = date("m") – $month;
$day_diff = date("d") – $day;
if ($day_diff < 0 || $month_diff < 0) $year_diff–;
return $year_diff;
}
Utilizzo:
echo 'Ho '.age('1981-11-12').' anni';
29. Utilizzo della memoria
Spesso si ha a che fare con errori del tipo "Exceed Memory limit", questa funzione nativa di PHP permette di scoprire quanta memoria l'applicazione sta utilizzando.
echo memory_get_usage() . "\n";
30. Connessione ed utilizzo del database
function connetti(){
mysql_connect('host', 'nome_utente', 'password_utente');
mysql_select_db('nome_db');
}
Utilizzo:
connetti();
31. Stampa di un calendario
A chi non fa comodo avere una funzione che genera un calendario a portata di mano?
L | M | M | G | V | S | D | \n"; else echo " | " . ($i - $startday + 1) . " | \n"; if (($i % 7) == 6) echo "\n"; } ?>
---|
Utilizzo:
print_calendar();
Fonte: http://snipplr.com/view.php?codeview&id=52989
32. Da timestamp a formato data
Conversione in PHP da formato timestamp a data
function timestamp_to_date($timestamp){
return date("r", $timestamp);
}
Utilizzo:
echo timestamp_to_date('timestamp_number');
33. Da formato data a timestamp
Può anche esservi utile il contrario:
function date_to_timestamp($data, $formato){
$a = strptime($data, $formato);
$timestamp = mktime(0, 0, 0, $a['tm_month'], $a['tm_day'], $a['tm_year']);
}
Utilizzo:
echo date_to_timestamp(22-09-2008', '%d-%m-%Y');
34. Aggiungere o rimuovere elemento da un array
Ecco alcune funzioni native di php che permettono in maniera veloce di aggiungere o rimuovere elementi da un Array
array_push: aggiunge uno o più elementi all'interno di un vettore
$stack = array("orange", "banana");
array_push($stack, "apple", "raspberry");
print_r($stack);
array_pop: rimuove uno o più elementi all'interno di un vettore
$stack = array("orange", "banana", "apple", "raspberry");
$fruit = array_pop($stack);
print_r($stack);
Fonte: php.net
35. Meteo realtime con le api di Google
Sfruttare le api di google per stampare informazioni relative al meteo.
function meteo($indirizzo){
$xml = simplexml_load_file('http://www.google.com/ig/api?weather=' . $indirizzo);
$information = $xml->xpath("/xml_api_reply/weather/current_conditions/condition");
return $information[0]->attributes();
}
Utilizzo:
echo meteo('Roma');
36. Parsing file csv
Snippet che apre ed effettua il parse di un file csv
$fh = fopen("contacts.csv", "r");
while($line = fgetcsv($fh, 1000, ",")) {
echo "Contact: {$line[1]}";
}
Fonte: http://phpbuilder.com/columns/Jason_Gilmore060210.php3?page=1
37. Verifica se una stringa è presente in un testo
function contains($str, $content, $ignorecase=true){
if ($ignorecase){
$str = strtolower($str);
$content = strtolower($content);
}
return strpos($content,$str) ? true : false;
}
38. Compressione di file CSS
Utilizzate un CSS che appesantisce di molto tutto il progetto? Niente paura, questa funzione comprime e alleggerisce a dovere rimuovendo al volo commenti, spazi, linee.
header('Content-type: text/css');
ob_start("compress");
function compress($buffer) {
/* remove comments */
$buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
/* remove tabs, spaces, newlines, etc. */
$buffer = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $buffer);
return $buffer;
}
/* your css files */
include('master.css');
include('typography.css');
include('grid.css');
include('print.css');
include('handheld.css');
ob_end_flush();
Fonte: http://www.phpsnippets.info/compress-css-files-using-php
39. Giorno, mese ed anno in dropdown
Questa funzione è utilissima per chi sviluppa da zero, stampa 3 dropdown menu con giorno mese ed anno
function mdy($mid = "month", $did = "day", $yid = "year", $mval, $dval, $yval)
{
if(empty($mval)) $mval = date("m");
if(empty($dval)) $dval = date("d");
if(empty($yval)) $yval = date("Y");
$months = array(1 => "January", 2 => "February", 3 => "March", 4 => "April", 5 => "May", 6 => "June", 7 => "July", 8 => "August", 9 => "September", 10 => "October", 11 => "November", 12 => "December");
$out = " ";
$out .= " ";
$out .= "";
return $out;
}
Fonte: http://www.codesphp.com/php-category/time-and-date/php-month-day-year-smart-dropdowns-2.html
40. Inviare Email con allegati
Linko una classe abbastanza completa che cura l'invio delle email con la possibilità di accodare allegati.
Utilizzo:
$sendmail = new AttachmentEmail('johnDoe@gmail.com', 'Testing mail() class', 'Your message here ', '/home/images/img.jpg');
$sendmail -> mail();
La classe è reperibile presso questo link http://www.codesphp.com/php-category/email/php-sending-email-with-attachment-using-mail.html.
15 comments
Fabiana Testini
17 Dicembre 2011 at 13:32
fantastico! Obbligherò il mio programmatore a prendere atto di queste funzioni dato che regna nel disordine più totale :S
Silvia Paldini
27 Dicembre 2011 at 20:51
non so se qualcuno può aiutarmi, ho un problema nell’invio mail con allegati (l’ultimo script inserito). ho copincollato il codice ma nessuna mail arriva a destinazione. Bisogna abilitare qualcosa? tnx
pierpaolo
29 Dicembre 2011 at 11:51
Ho un problema sullo script N° 27: Generazione del captcha in PHP.
Ho eseguito alla lettera ma alla prima istruzione mi parte sto errore/orrore:
Non mi permette di andare avanti!
Semiur web designer
3 Gennaio 2012 at 17:30
hai uno script per leggere gli rss esterni?
ps: bel blog, messo su davvero molto bene!
Mario Concina
6 Gennaio 2012 at 15:55
Non sembra un problema di percorso ma di permessi, “Permission Denied”. Prova ad impostare i CHMOD a 777 nella cartella in cui estrai lo zip.
Phil
13 Gennaio 2012 at 17:32
Ottimo post. Grazie Mario!!
Arianna Alberghi
27 Marzo 2012 at 21:34
Grazie davvero, tutte interesati ma alcune preziosissime. Dritto nei preferiti 🙂
Fabio Monti
15 Giugno 2012 at 16:14
Messe tra i preferiti!
Una serie di snippet in più sono sempre utili!
Grazie!
Giulio
25 Ottobre 2012 at 15:14
molto molto utili grazie! 😀
alberto
26 Novembre 2012 at 22:05
ottimi i tuoi snippet, però per quanto riguarda il punto 6, per quanto il tuo metodo sia corretto ed usuale, ti suggerisco di farlo così:
while (gettype($file = readdir($dir_handle)) != boolean) { .... }
perché se la directory contiene file del tipo: “0”, “12”… rischi un listing errato del tipo:
. ..
Mario Concina
27 Novembre 2012 at 15:20
Grazie per il suggerimento, è sempre meglio migliorare! 😉
Luca
4 Maggio 2013 at 6:57
Raccolta davvero preziosa, complimenti!! L’ho messa tra i preferiti! Se te ne vengono altre da aggiungere fai pure! E grazie!
Decadeweb
24 Luglio 2013 at 20:21
Ottimo articolo! Ho provato lo script per recuperare i twitter ma utilizza ancora le api vecchie e non funziona correttamente!..
Mario Concina
25 Luglio 2013 at 14:48
Ciao,
grazie per la segnalazione. Tra l’altro la scorsa settimana ho scritto un articolo a riguardo.
Ultimi tweet sul proprio sito con le nuove api oAuth
Pingback: Favoriti | Daniele Milana