Archive for the ‘Funciones’ Category
Domingo, Octubre 26th, 2008
Esto lo he necesitado porque al pasar de PHP 4 a PHP 5 la clase catpcha.php dejo de funcionar, el problema era que no encontraba la ruta de Verdana.ttf.
Lo he solucionado así:
Subo a la carpeta includes el fichero Verdana.ttf
y sustituyo:
define ("FONTNAME", "Verdana.ttf");
por
define ("FONTNAME", dirname (__FILE__)."/Verdana.ttf");
Con esto funciona.
dirname (__FILE__) devuele la ...
Posted in Funciones | No Comments »
Viernes, Octubre 24th, 2008
funcion shell_exec de php.
y que esta función no está habilitada en safe-mode.
Posted in Funciones | No Comments »
Domingo, Agosto 10th, 2008
Obtener un fragmento de una Cadena (String)
Visual Basic:
[VB]
Dim MyString As String
MyString = "This is string example"
MsgBox Mid(MyString, 5, 10)
[/VB]
PHP:
[PHP]
$MyString = "This is string example";
echo substr($MyString,5,10);
[/PHP]
Nota: En ambos casos el contador de caracteres empieza en 0
Posted in Funciones, Visual Basic | No Comments »
Viernes, Mayo 30th, 2008
Para separar un string en varias partes en función de un caracter determinado:
[php]
$string = "Alex;Pedro;Jose;Carlos";
$names = explode(";",$string);
echo $names[0];
echo $names[1];
[/php]
Posted in Funciones | No Comments »
Domingo, Mayo 25th, 2008
[php]
Posted in Funciones | No Comments »
Sábado, Mayo 17th, 2008
Por ejemplo saber si en un campo de texto han introducido una url (http, www, etc.), esto es útil para evitar robots que nos envían url automaticamente.
En este ejemplo primero se crea una matriz con los string que queremos buscar:
[php]
function patron_msg() {
$_msg[] = "href";
$_msg[] ...
Posted in Funciones | No Comments »
Sábado, Mayo 17th, 2008
[php]
[/php]
Posted in Funciones | No Comments »
Sábado, Mayo 17th, 2008
[php]
/**
* Extraer Tags entre corchetes []
* Ejemplo de Bucle For
* Ejemplo de recorrer un string
* Ejemplo de Substring
*
* @param String $p_string String to analyze
* @param String $p_begin Character begin label
* @param String $p_end Character end label
* @return ...
Posted in Funciones | No Comments »
Jueves, Mayo 15th, 2008
[php]
/**
* Redimensionar imagen a formato banner predeterminado 200 x 60
*
* @param unknown_type $p_banner_file, $p_width anchura deseada, $p_height altura deseada
* @return String con los parametros width y height rellenados
*/
function image_banner_size($p_image_file, $p_width = 200, $p_height = 60)
{
if (!file_exists($p_image_file))
{
return "";
}
$imagesize = getimagesize("$p_image_file");
$width_height = " width=\"". $imagesize[0]."\" height=\"". ...
Posted in Funciones | No Comments »
Lunes, Mayo 12th, 2008
Funciones de tratamiento de String en PHP:
Pasar String a minúsculas
[php]
$str = "Hola esto es UNion";
$str = strtolower($str);
[/php]
strong>Buscar un String dentro de otro
Distinguiendo Mayúsculas de minúsculas
[php]
$str = "Hola esto es UNION";
if (strpos($str,"UNION") > 0) ...
[/php]
Sin distinguir (solo en PHP5):
[php]
$str = "Hola esto es UnIoN";
if (stripos($str,"UNION")
...
[/php]
Posted in Funciones | No Comments »