elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Usando Git para manipular el directorio de trabajo, el índice y commits (segunda parte)


  Mostrar Mensajes
Páginas: 1 2 3 4 [5] 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ... 31
41  Programación / PHP / Re: Salidas de una función en: 22 Diciembre 2011, 17:27 pm
Código
  1. <?php
  2.  
  3.  echo "El resultado de sumar 5 y 6 es ";
  4.  echo sumador(5,6); //Llamada a la función
  5.  
  6.  function sumador($num1,$num2){
  7.    $resultado = $num1 + $num2;
  8.    return $resultado;
  9.  }
  10.  
  11. ?>

Con return, se hace la suma y la misma llamada a la función toma el valor del resultado. Sin el return solo se hace la suma.
42  Programación / PHP / Re: Problema con (int) en: 22 Diciembre 2011, 16:31 pm
Ya te entiendo. Tienes razón, sería algo muy bueno para la seguridad.
Me interesa éste tema, voy a buscar a ver si encuentro algo. Si encuentras algo, publícalo por favor :)

Aunque se sabe que PHP actualiza el tipo de variable cada vez que se le asigna un valor a esta.

¿No se podría verificar el dato que entra antes de asignarlo?
Código
  1. <?php
  2.  $dato = "a";
  3.  if(gettype($dato)=="integer"){
  4.    $suma = $dato;
  5.    echo $suma;
  6.  }else{
  7.    echo "El dato debe ser un n&uacute;mero entero.";
  8.  }
  9. ?>
43  Programación / PHP / Re: Problema con (int) en: 22 Diciembre 2011, 16:01 pm
PHP: Manipulación de tipos - Manual
44  Programación / Desarrollo Web / Re: Ayuda con el desarrollo de un formulario en: 20 Diciembre 2011, 19:28 pm
Como dice Lipman, puedes usar onKeyDown así...
Código
  1. <html xmlns="http://www.w3.org/1999/xhtml">
  2.  
  3.  <title></title>
  4. </head>
  5.  
  6.  
  7.  <form name="formulario">
  8.    Tel&eacute;fono: <input name="tel" type="text" onKeyDown="comprobar()" /><br/>
  9.    Otro campo: <input name="otro" type="text" />
  10.  </form>
  11.  
  12.    <script type="text/javascript">
  13.      function comprobar(){
  14.        if(document.formulario.tel.value.length >= 9){
  15.          document.formulario.otro.focus();
  16.        }        
  17.      }
  18.    </script>
  19.  
  20. </body>
  21.  
  22. </html>
45  Programación / Desarrollo Web / Re: Cerrar ventana popup o float al hacer click en su contenido en: 15 Diciembre 2011, 07:10 am
Acá te dejo un ejemplo báscio que hice, espero que te sirva.

Código
  1. <html xmlns="http://www.w3.org/1999/xhtml">
  2.  
  3.  <title></title>
  4.  <style type="text/css">
  5.    .anuncio
  6.    {
  7.      background-color:#FF5555;
  8.      padding:20px;
  9.    }
  10.  </style>
  11. </head>
  12.  
  13.  
  14.  <div class="anuncio" id="publi" onClick="ocultar()">Este es el anuncio. (Hacer click)</div>
  15.  
  16.    <script type="text/javascript">
  17.      function ocultar(){
  18.        document.getElementById("publi").style.visibility = 'hidden';
  19.      }
  20.    </script>
  21.  
  22. </body>
  23.  
  24. </html>
46  Programación / PHP / Re: Graficos de barras en php en: 14 Noviembre 2011, 02:25 am
Es verdad, a veces nos obligan a aprender cosas para poder obtener un titulo. Si sabes que despues no lo necesitas, se siente mal. Pero qué bueno que te estés esforzando y quieras ayudar a alguien más :-)

PD. Yo también soy pato para esto peri trato de entender bien la documentación.
47  Programación / PHP / Re: Graficos de barras en php en: 13 Noviembre 2011, 18:24 pm
Te felicito, algunos usuarios solo esperan a que hagan el trabajo por ellos :)
Yo haría una gráfica de barras algo así:
Código
  1. <?php
  2. $myImage = ImageCreate(400,300);
  3.  
  4. $white = ImageColorAllocate($myImage, 255, 255, 255);
  5. $yellow  = ImageColorAllocate($myImage, 255, 255, 0);
  6. $red  = ImageColorAllocate($myImage, 255, 0, 0);
  7. $green = ImageColorAllocate($myImage, 0, 255, 0);
  8. $blue = ImageColorAllocate($myImage, 0, 0, 255);
  9. $darkgray = ImageColorAllocate($myImage, 127, 127, 127);
  10. $black = ImageColorAllocate($myImage, 0, 0, 0);
  11.  
  12. $fuente = "arial.ttf";
  13.  
  14.  
  15. imageline ($myImage, 50, 240, 260, 240, $darkgray);
  16. imageline ($myImage, 50, 40, 50, 240, $darkgray);
  17.  
  18. imagettftext($myImage, 10, 0, 26, 243, $black, $fuente, "  0");
  19. imagettftext($myImage, 10, 0, 26, 210, $black, $fuente, " 20");
  20. imagettftext($myImage, 10, 0, 26, 177, $black, $fuente, " 40");
  21. imagettftext($myImage, 10, 0, 26, 144, $black, $fuente, " 60");
  22. imagettftext($myImage, 10, 0, 26, 111, $black, $fuente, " 80");
  23. imagettftext($myImage, 10, 0, 26, 78, $black, $fuente, "100");
  24.  
  25.  
  26. //Los datos llegan de 0 a 100 (porcentaje)
  27. $numero1 = 20;
  28. $numero2 = 40;
  29. $numero3 = 60;
  30. $numero4 = 100;
  31.  
  32. $dato1 = 240-(((240-75)/100)*$numero1);
  33. $dato2 = 240-(((240-75)/100)*$numero2);
  34. $dato3 = 240-(((240-75)/100)*$numero3);
  35. $dato4 = 240-(((240-75)/100)*$numero4);
  36.  
  37. ImageFilledRectangle($myImage, 70, 240, 90, $dato1-1, $darkgray);
  38. ImageFilledRectangle($myImage, 71, 239, 89, $dato1, $blue);
  39.  
  40. ImageFilledRectangle($myImage, 110, 240, 130, $dato2-1, $darkgray);
  41. ImageFilledRectangle($myImage, 111, 239, 129, $dato2, $red);
  42.  
  43. ImageFilledRectangle($myImage, 150, 240, 170, $dato3-1, $darkgray);
  44. ImageFilledRectangle($myImage, 151, 239, 169, $dato3, $green);
  45.  
  46. ImageFilledRectangle($myImage, 190, 240, 210, $dato4-1, $darkgray);
  47. ImageFilledRectangle($myImage, 191, 239, 209, $dato4, $yellow);
  48.  
  49. header ("Content-type: image/png");
  50. ImagePng($myImage);
  51. ImageDestroy($myImage);
  52. ?>

Recuerda agregar el archivo arial.ttf en el mismo directorio de tu .php
48  Programación / PHP / Re: Graficos de barras en php en: 13 Noviembre 2011, 05:54 am
Hola inquilin@19 :)
Podrías hacer un plano con lineas, valores y las barras. Para separar las barras 20px debes usar los atributos de la función ImageFilledRectangle() ya que esta recibe dos puntos para gráficar el rectángulo, pronto agregaré un ejemplo en éste tema.
49  Programación / PHP / Re: Reproducir audio en php? en: 5 Noviembre 2011, 07:31 am
PHP genera HTML.
50  Programación / PHP / Re: ¿Que esta mal? [Correccion de codigo] en: 4 Noviembre 2011, 03:55 am
Si sabes de que forma recibira los datos (POST) porque optar por usar REQUEST ?
Me quedo esa duda jeje

Yo pregunto lo mismo... Esto podría ser algo potencialmente malo en cuanto a seguridad.
Páginas: 1 2 3 4 [5] 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ... 31
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines