Tags: php

Sort by: Date / Title /

  1. 4 months ago by spirit
    Ça parait simple comme ça mais ça m'a pris du temps de trouver, donc pas la peine de le perdre :)
    1. rand(0,1)*2-1
  2. 4 months ago by spirit
    1. function distance($lat1, $lon1, $lat2, $lon2, $unit) {
    2.  
    3.   $theta = $lon1 - $lon2;
    4.   $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2))cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
    5.   $dist = acos($dist);
    6.   $dist = rad2deg($dist);
    7.   $miles = $dist * 60 * 1.1515;
    8.   $unit = strtoupper($unit);
    9.  
    10.   if ($unit == "K") {
    11.     return ($miles * 1.609344);
    12.   } else if ($unit == "N") {
    13.       return ($miles * 0.8684);
    14.     } else {
    15.         return $miles;
    16.       }
    17. }
    18.  
    19. echo distance(32.9697, -96.80322, 29.46786, -98.53506, "m") . " miles<br>";
    20. echo distance(32.9697, -96.80322, 29.46786, -98.53506, "k") . " kilometers<br>";
    21. echo distance(32.9697, -96.80322, 29.46786, -98.53506, "n") . " nautical miles<br>";
  3. 6 months ago by spirit
    1. /etc/apache2/apache2.conf
    2. > ServerTokens Prod
    3. > ServerSignature Off
    4.  
    5. /etc/php5/apache2/php.ini
    6. > expose_php = Off
  4. sponsorised links
  5. 6 months ago by cyo
    1. wget --timeout=0 -q -t 1 -O -  http://127.0.0.1/path/file.php >result.txt 2>result.txt
    2. SORTIE=`cat result.txt | tr '\015\012' ' '`
    3. echo $SORTIE
  6. 7 months ago by jacinmontava
    1. <?php
    2.  
    3. $dbhost = "servidor"; $dbuser = "usuario"; $dbpassword = "clave"; $dbname = "base_de_datos";
    4. mysql_connect($dbhost,$dbuser,$dbpassword);
    5. $tablas = mysql_list_tables($dbname);
    6.  
    7. while (list($tabla) = mysql_fetch_row($tablas)) {
    8. echo $tabla."<br />";
    9. } ?>
  7. 8 months ago by fozter
    1. <?php
    2.  
    3. function imprimeFecha()
    4. {
    5.         $dias = array('Domingo','Lunes','Martes','Mi&eacute;rcoles','Jueves','Viernes','S&aacute;bado');
    6.         $meses = array('Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre');
    7.  
    8.          echo 'Hoy es '.$dias[date('w')].' '.date('j').' de '.$meses[date('n')-1].' del '.date('Y');
    9. }
    10.  
    11. // Ejemplo: Hoy es Viernes 31 de Octubre del 2008
    12.  
    13. ?>
  8. 8 months ago by fozter
    Necesario para eliminar el cache del explorador cuando se utiliza ajax para mostrar resultados en un contenedor div
    1. <?
    2.   header("Expires: Tue, 01 Jul 2001 06:00:00 GMT");
    3.   header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    4.   header("Cache-Control: no-store, no-cache, must-revalidate");
    5.   header("Cache-Control: post-check=0, pre-check=0", false);
    6.   header("Pragma: no-cache");
    7. ?>
  9. 8 months ago by sx
    1. preg_replace('/\\s{2,}/',' ',$string);
  10. 8 months ago by cyo
    Le 'slash' indique que l'on effectue la recherche sur tout le serveur (à partir de la racine)
    1. find / -name php.ini
  11. 8 months ago by spirit
    1. $start = microtime(TRUE);
    2. // Code PHP à bencher
    3. for ($i = 0; $i < 10000; $i++)
    4. {
    5.     isset($array['id']);
    6. }
    7.  
    8. echo number_format(microtime(TRUE) - $start, 6)." seconds: isset\n";

First / Previous / Next / Last / Page 1 of 9 (83 posteets)