background preloader

PHP

Facebook Twitter

Site Web indisponible. Accessing Incoming PUT Data from PHP. Recently I started writing a REST service.

Accessing Incoming PUT Data from PHP

I began in the usual way, writing a php script, calling it with a GET request, accessing the variables using the PHP superglobal variable $_GET. I wrote code to handle a POST request and used the variables I found in $_POST. Then I tried to write a PUT request. PHP doesn't have a built-in way to do this, and at first I was a little confused as to how I could reach this information. It turns out that this can be read from the incoming stream to PHP, file_get_contents(" The above line provided me with a query string similar to what you might see on the URL with a GET request. key/value pairs separated by question marks.

Parse_str(file_get_contents(" This loads the variable $post_vars with the associative array of variables just like you'd expect to see from a GET request. Simple Example Its a bit of a contrived example but it shows use of the REQUEST_METHOD setting from the $_SERVER variable to figure out when we need to grab the post vars. PhpDocumentor tags. Welcome to the phpDocumentor Tags Manual phpDocumentor tags are very similar to tags for the JavaDoc tool for Sun's Java Programming Language.

phpDocumentor tags

Tags are only parsed if they are the first thing on a new line of a DocBlock. You may use the @ character freely throughout documents as long as it does not begin a new line. An example: /** * tags demonstration * @author this tag is parsed, but this @version tag is ignored * @version 1.0 this version tag is parsed */ Any tags that phpDocumentor does not recognize will not be parsed, and will be displayed in text flow as if they are part of the DocBlock long description. /** * tags demonstration * @foobar this is silly * @author this tag is parsed, but this @version tag is ignored */ Inline tags display in the text flow where they appear, and are not separated from the description. /** * inline tags demonstration * * this function works heavily with {@link foo()} to rule the world */function bar(){}function foo(){}

Algunas trucos de optimización de código PHP. 1 – Inicializa las variables antes de utilizarlas.

Algunas trucos de optimización de código PHP

Cómo optimizar tus aplicaciones PHP. La optimización de aplicaciones PHP nos ayuda a desarrollar aplicaciones rápidas, pero que a la vez cuenten con calidad y eficiencia.

Cómo optimizar tus aplicaciones PHP

Nuestros usuarios necesitan de aplicaciones que resuelvan los problemas en el menor tiempo posible. Los sitios web necesitan ser rápidos, sin tomar en cuenta el tamaño del mismo. Es por ello que el principal objetivo al desarrollar una aplicación está en su optimización. Funciones para optimizar scripts PHP. Funciones para optimizar scripts PHP Buscar y encontrar ficheros en PHP con GLob() Muchas funciones en PHP tienen nombres largos y descriptivos, sin embargo es difícil saber que hace una función llamada glob(), a no ser que lo busques en la documentación o ya la hayas usado previamente.

Funciones para optimizar scripts PHP

Es una función mucho más potente que scandir() ya que también permite búsqueda de ficheros usando patrones. // buscados todos los archivos con extensión .php, podría ser cualquier otra extensión. DateInterval. Formato date PHP. Most spreadsheet programs have a rather nice little built-in function called NETWORKDAYS to calculate the number of business days (i.e.

Formato date PHP

Monday-Friday, excluding holidays) between any two given dates. I couldn't find a simple way to do that in PHP, so I threw this together. It replicates the functionality of OpenOffice's NETWORKDAYS function - you give it a start date, an end date, and an array of any holidays you want skipped, and it'll tell you the number of business days (inclusive of the start and end days!) Between them. I've tested it pretty strenuously but date arithmetic is complicated and there's always the possibility I missed something, so please feel free to check my math. The function could certainly be made much more powerful, to allow you to set different days to be ignored (e.g.

PHPMailer in CodeIgniter - PHP's Blog. In a previous post I talked about how to use the library PHPMailer to send emails from our website without having our own mail server running on the machine.

PHPMailer in CodeIgniter - PHP's Blog

This time we will go a step further and explain how to integrate this library in our CodeIgniter project and not die in the attempt. The first thing we do, if we have not done it yet, will be to download the library. Once we unzip the library, we can rename the folder named PHPMailer and move it to the folder /system/application/libraries (for CodeIgniter 1.7.3 or previous) or to the folder /application/libraries/ (for CodeIgniter 2.0 or later) in our CodeIgniter application. Once we did it so, we can start to implement our own library, which will be in charge of including PHPMailer into our application. Encriptar y desencriptar cadena con PHP. Cualquier programador Web ha podido necesitar pasar datos por $_GET – en la url – , es una forma fácil y cómoda de pasar valores de una página a otra, pero… en algunos casos puede no ser recomendable y habría que tener un mínimo de precaución, y para estos casos – y otros muchos – se puede utilizar esta clase que un día vi – no se donde, si lo supiese pondría la fuente – y sobre la que me veo obligado a escribir, mas que nada para tenerla presente yo mismo y darla a conocer a quien pueda necesitarla.

Encriptar y desencriptar cadena con PHP

PHP - Email Headers. Headers are the parts seen at the top of emails.

PHP - Email Headers.

Typically : The TO and SUBJECT filds have already been discussed as the first and second variables in the MAIL command. The extra headers seen above can be entered as a 4th variable in the MAIL command. Looks kinda messy when it's all in there without using variables. That above example has all of the extra headers being declared. You may specify all or some or none as you desire. $to = "yourplace@somewhere.com"; $subject = "My email test.