Cateva trucuri (PHP, MySQL)

Am incropit o lista scurta cu optimizari / trucuri pentru PHP si baze de date MySQL. Probabil in timp voi actualiza lista.

1. Redirectionare pe un website fara a “specifica” si referinta

<?php
$header_redirect = 'Location: ' . $_GET['website'];
header($header_redirect);

2. Cea mai simpla metoda de optimizare a unei tabele MySQL

<?php
mysql_query("OPTIMIZE TABLE nume_tabela") or die(mysql_error());

3. Afiseaza fisierele dintr-un folder

<?php
// calea catre folder
$path = '/home/website/public_html/';
$dir_handle = @opendir($path) or die('Nu pot deschide ' . $path);
while ($file = readdir($dir_handle))
{
	if ($file == '.' || $file == '..') 
	{ 
		$file == '';
	}
	else
	{
		echo $file . '
'; } } closedir($dir_handle);

Leave a Reply

Your email address will not be published. Required fields are marked *