PHP command line syntax checking Posted April 24th, 2010 in PHP The PHP CLI (command line interface) allows basic syntax checking of a PHP file. I'll show the basic usage of this in this post and then a couple of ways to check all files in a directory, and all files recursively down the directory tree as posted by a couple of people on Twitter. Syntax checking a single PHP file from the command line The syntax for checking is like this, where the -l flag is a lower case L: If the syntax in the file is correct you will see this: If there are errors then theses will be listed as in the following example output: Note that the syntax checking only checks for syntax errors - it does not report the usage of variables which have not yet been defined, functions or class which have not be declared etc. So something like this will pass: but these will not: Syntax check all PHP files in the current directory
Apache PHP MySQL and Runaway Scripts | MySQL Performance Blog May 20, 2008 by Peter Zaitsev20 Comments Sometimes due to programming error or due to very complex query you can get your PHP script running too long, well after user stopped waiting for the page to render and went browsing other sites. Looking at Server-Status I’ve seen scripts executing for hours sometimes which is obviously the problem – they take Apache Slot, MySQL Connection and other resources. I had discussion today who was thinking Apache would kill the script after “Timeout” specified in Apache configuration is reached – this was not my experience so I decided to run couple of tests to check it. I wrote couple of very simple scripts which demonstrate different behavior for scripts running very long time. Script which simply runs in tight loop “forever” Script which runs in tight loop but doing a lot of sleep() calls – so it takes a lot of time but does not really use any CPU time: Script which is same as previous one but which also outputs some data in the loop: Another one:
PDF Generation with Zend Framework | LiveDocx in PHP - Zend_Service_LiveDocx Generating print-ready well-formatted PDF documents with PHP is not an easy task. Traditionally, there are two main approaches to PDF generation with PHP. Given sufficient time and patience, both partially get the job done, but still leave a lot to be desired: HTML-to-PDF: This approach is widely used in mainstream applications. Programmatic: This approach offers total control of the resulting PDF. A completely new approach In this article, the author presents an entirely new, third approach. Before we delve into a technical discussion on the inner workings of this new approach, let us first take a look at a practical example. The code demonstrated in this article ships with Zend Framework 1.10 or newer. Introducing LiveDocx LiveDocx is a SOAP-based document generation service, based on the market-leading, word processing component TX Text Control .NET. Templates and documents Throughout this article, we refer to the terms templates and documents. Using LiveDocx and Learn more Footnotes
Xdebug - Debugger and Profiler Tool for PHP 15 very useful PHP code snippets for PHP developers | ViralPatel.net Following are list of 15 most useful PHP code snippets that a PHP developer will need at any point in his career. Few of the snippets are shared from my projects and few are taken from useful php websites from internet. You may also want to comment on any of the code or also you can share your code snippet through comment section if you think it may be useful for others. 1. Send Mail using mail function in PHP 2. 3. The above code will not work in case your client is behind proxy server. 4. This function will return the duration of the given time period in days, hours, minutes and seconds. e.g. secsToStr(1234567) would return “14 days, 6 hours, 56 minutes, 7 seconds” 5. 6. Required Extension: SimpleXML 7. 8. Following is the PHP code to create the JSON data format of above example using array of PHP. Following code will parse the JSON data into PHP arrays. 9. 10. This basic snippet will create a random authentication code, or just a random string. 11. Validate a date in “YYYY-MM-DD” format.
A Guide to Cryptography in PHP n an ideal world, words like cryptography and security wouldn't even exist, but the real world is far from perfect, so software developers have to spend a good deal of time building security into applications. Cryptography is just one piece of the security puzzle, along with SSL/TLS, certificates, digital signatures, and so on. This article explains how to use PHP to implement the most common cryptographic algorithms. The code examples in this article use the contents of a short text file, textfile.txt, which contains the following plain-text content: For every difficult and complicated question there is an answer that is simple, easily understood, and wrong. Default PHP Encryption Functions PHP ships with three built-in encryption functions: md5(), crypt(), and sha1(). string md5(string $str [, bool $raw_output ]) The function calculates the MD5 hash of a supplied string using the MD5 Message-Digest algorithm. string crypt (string $str [, string $salt ]) Table 1.
Top 20+ MySQL Best Practices Database operations often tend to be the main bottleneck for most web applications today. It's not only the DBA's (database administrators) that have to worry about these performance issues. We as programmers need to do our part by structuring tables properly, writing optimized queries and better code. In this article, I'll list some MySQL optimization techniques for programmers. Before we start, be aware that you can find a ton of useful MySQL scripts and utilities on Envato Market. Most MySQL servers have query caching enabled. The main problem is, it is so easy and hidden from the programmer, most of us tend to ignore it. The reason query cache does not work in the first line is the usage of the CURDATE() function. Using the EXPLAIN keyword can give you insight on what MySQL is doing to execute your query. The results of an EXPLAIN query will show you which indexes are being utilized, how the table is being scanned and sorted etc... After adding the index to the group_id field:
Useful articles and tutorials JpGraph - Most powerful PHP-driven charts (Simple version)Matrix like animated dropping character effect i Like most animated effects I will ever make, it needs GIFEncoder class . The basic idea: On a screen, when one pixel is activated, it lights up. Here, instead of a pixel, it is a character, so I just have to construct a character grid and light them when it is activated. include ( 'GIFEncoder.class.php' ) ; ob_start ( ) ; $msg = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890~! Please download your own true type fonts. If you want to find a property through the banks , be ready for a detailed scrutiny of your insurance deals as well as credit report .
7 Secure, Lightweight, and Easy to Use PHP Frameworks Choosing a good PHP frameworks can help you develop complex Rich Internet Applications quickly, with a best practices oriented approach, and saving a lot of time reusing code snippets that are already available. There are a lot of interesting PHP frameworks you can choose for your next web project. Which framework you choose is really a personal decision. There is no one “best” framework on the market at the moment. Different frameworks are better for different types of projects, and for different developer. Today we will focus on 7 secure, lightweight and easy to use PHP Frameworks. Why Use a PHP Framework? There are plenty of reasons to use a PHP Framework to build your websites. 1. Below we’ve covered some of the best frameworks available today. 1. CodeIgniter is a powerful, high-performance, open-source PHP framework that helps you author PHP applications rapidly. CodeIgniter has an exciting online manual, a couple of helpful video tutorials and an active user forum. 2. 3. 4. 5. 6. 7.