10 Things You Can Do to Become a Better PHP Developer PHP is probably the most popular web development language right now. At least 20 million domains use PHP and it’s the language used on major sites such as Wikipedia and Facebook as well as in some of the world’s biggest open source projects like WordPress and Drupal. In this article, I’ll share with you ten things I wish I was told when I was just getting started with PHP development, and I’m hoping you’ll be able to learn a thing or two if you’re just taking your first steps into this awesome web development language. 1. Use PHP Core Functions and Classes If you’re trying to do something that seems fairly common, chances are, there’s already a PHP function or class that you can take advantage of. 2. Instead of having your database connection settings scattered everywhere, why not just create one master file that contains its settings, and then include it in your PHP scripts? Using a config file is a popular web application pattern that makes your code more modular and easier to maintain.
PHPMailer tutorial This is meant to be an improved version of the article written by PHPFreaks founder, Eric Rosebrock on the PHPFreaks site HERE, simply because I noticed the URL for that tutorial often was down, so I rewrote it (close to verbatim) for my own personal use. PHPMailer is by far the BEST way to add email functionality to your web site. This is just an article to point you in the right direction to mastering this incredible php package. Tutorials, Guides, Documentation, and HowTos ^ Other PHPMailer links ^ Introduction ^ Sending E-Mail through PHP can be simple, or it can be very complex depending on what you want to do. Requirements ^ The requirements of this tutorial are very limited. Don't sweat it, this is going to be an easy tutorial for you to follow! About PHPMailer ^ PHPMailer is a fully featured email transfer class for PHP that I would put above all of the other E-Mail handlers that I've used. PHPMailer Features ^ PHPMailer Contributors ^ The following contributors to PHPMailer are: Brent R.
PHP MVC from the scratch - How to connect these classes Comprehensive guide to .htaccess- intro Tutorial written and contributed by Feyd, moderator of the JK Forum, with additions by JavaScriptKit.com. Please see tutorial footnote for additional/bio info on author. Last updated: Jan 18th, 06' for additional section. I am sure that most of you have heard of htaccess, if just vaguely, and that you may think you have a fair idea of what can be done with an htaccess file. You are more than likely mistaken about that, however. If you have heard of htaccess, chances are that it has been in relation to implementing custom error pages or password protected directories. An htaccess file is a simple ASCII file, such as you would create through a text editor like NotePad or SimpleText. .htaccess is the file extension. Now, onto the tasty morsels...
.htaccess tricks and tips.. part one: tips, tricks, hints, examples; juicy .htaccess information. corz.org uses cookies to remember that you've seen this notice explaining that corz.org uses cookies, okay! <ifModule> clever stuff here </ifModule> Introduction to .htaccess.. This work in constant progress is some collected wisdom, stuff I've learned on the topic of .htaccess hacking, commands I've used successfully in the past, on a variety of server setups, and in most cases still do. ..an old Win32 Apache mirror of corz.org .htaccess files are invisible There's a good reason why you won't see .htaccess files on the web; almost every web server in the world is configured to ignore them, by default. If you don't see, you'll need to disable your operating system's invisible file functions, or use a text editor that allows you to open hidden files, something like bbedit on the Mac platform. In the image, the operating system has been instructed to display invisible files. ugly, but necessary sometimes. By the way; that folder is no longer there. What are .htaccess files anyway? 500 error..
DevNetwork Forums • Index page php - Understanding MVC Constructors and Destructors USE PARENT::CONSTRUCT() to exploit POLYMORPHISM POWERS Since we are still in the __construct and __destruct section, alot of emphasis has been on __destruct - which I know nothing about. But I would like to show the power of parent::__construct for use with PHP's OOP polymorphic behavior (you'll see what this is very quickly). In my example, I have created a fairly robust base class that does everything that all subclasses need to do. Here's the base class def. <? abstract class Animal{ public $type; public $name; public $sound; public function __construct($aType, $aName, $aSound) { $this->type = $aType; $this->name = $aName; $this->sound = $aSound; } public static function compare($a, $b) { if($a->name < $b->name) return -1; else if($a->name == $b->name) return 0; else return 1; } public function __toString() { return "$this->name the $this->type goes $this->sound"; } } ? $myPet = new Animal("Parrot", "Captain Jack", "Kaaawww!") usort($animals, array("Animal", "compare")); ?
Blocking access to the login page after three unsuccessful login attempts Sometimes you need to add an extra protection to password-protected website. This article explains how access to the login page can be restricted after three unsuccessful login attempts. This schema uses visitors IP address to store log attempts in the database and block access to login feature for 30 minutes after third unsuccessful attempt. There are a number of reasons to restrict access. One reason is security. So let's start. It is assumed that you have already had an authorization page. Authorization page should work with two tables: one table where information about registered users is stored and the other one where unsuccessful login attempts are listed. If attempts limit has not been reached, then the system will check, if the data entered are correct.
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.
How do you use the MVC paradigm in PHP with ADODB as your DAL Request Processing in Apache Now that we have an overview of request processing in Apache, we can proceed to show how a module hooks into it to play a part. The apache module structure declares several (optional) data and function members: module AP_MODULE_DECLARE_DATA my_module = { STANDARD20_MODULE_STUFF, my_dir_conf, my_dir_merge, my_server_conf, my_server_merge, my_cmds, my_hooks } ; The relevant function for the module to create request processing hooks is the final member: static void my_hooks(apr_pool_t* pool) { /* create request processing hooks as required */ } What hooks we need to create here depend on what part or parts of the request our module is interested in. ap_hook_handler(my_handler, NULL, NULL, APR_HOOK_MIDDLE) ; Now my_handler will be called when a request reaches the content generation phase. ap_hook_post_read_request First chance to look at the request after accepting it. ap_hook_fixups Last chance to look at the request before content generation. ap_hook_log_transaction Logging hook.
Protección anti CSRF con tokens en PHP | EsLoMas.com En este post voy a explicar cómo proteger nuestras aplicaciones PHP contra ataques de tipo CSRF. Este tipo de ataques hacen que el usuario realice acciones sobre un web de forma inadvertida. Por ejemplo, en una página vulnerable a este tipo de ataques, podrían construirse páginas de ataque en las que únicamente con la visita del usuario se modificase su información de registro, se publicase información de forma oculta, etc. Imaginemos que estamos conectados a un web que requiere autenticación y que por ejemplo estamos manteniendo una conversación por chat con otra persona. Una forma de evitar esta vulnerabilidad es utilizar tokens de autorización en cada acción que se realiza sobre el servidor. Esta forma de generación de tokens se basa en la creación de tokens específicos para cada tipo de acción realizable en la aplicación y el registro de estos tokens en la sesión del usuario. La siguiente función permite comprobar la validez de los tickets generados.
foreach You can even iterate through "dynamic" arrays that do not physically exist, but are objects that implement Iterator interface. They don't need to be stored in memory when foreach starts. Consider the array that contains some values (I called it $allValues in the example below) and we want to have only some of them (eg. the ones that are dividable by 2). I create an object that would serve as dynamic array, that means it would "dynamically update" its values together with $allValues. An object of MyIter class will not contain any values itself:<? private function getTable(){ global $allValues; $result=array(); foreach($allValues as $obj){ if($obj % 2 == 0) $result[]=$obj; } return $result; } function rewind() { $this->position = 0; } function current() { $table=$this->getTable(); return $table[$this->position]; } function key() { return $this->position; } function next() { ++$this->position; } function valid() { return array_key_exists($this->position, $this->getTable()); }}