background preloader

PHP

Facebook Twitter

WebSockets

Building Web Applications from Scratch with Laravel. Style de codage. If / Else / Elseif Les structure de contrôles basées sur les constructions if et elseif doivent avoir un seul espace avant la parenthèse ouvrante de la condition, et un seul espace après la parenthèse fermante. Pour la condition entre les parenthèses, les opérateurs doivent être séparés par des espaces pour une meilleure lisibilité. Les parenthèses internes sont conseillées pour améliorer le regroupement logique de longues conditions. L'accolade ouvrante est écrite sur la même ligne que la condition. L'accolade fermante est toujours écrite sur sa propre ligne. If the conditional statement causes the line length to exceed the maximum line length and has several clauses, you may break the conditional into multiple lines. If (($a == $b) && ($b == $c) || (Foo::CONST == $d)) { $a = $d;} The intention of this latter declaration format is to prevent issues when adding or removing clauses from the conditional during later revisions.

Switch. Using Traits in PHP 5.4 » phpmaster. Minimizing code duplication through better organization and code reuse is an important goal of Object Oriented Programming. But in PHP it can sometimes be difficult because of the limitations of the single inheritance model it uses; you might have some methods that you would like to use in multiple classes but they may not fit well into the inheritance hierarchy. Languages like C++ and Python allow us to inherit from multiple classes which solves this problem to some extent, and mixins in Ruby allows us to mix the functionality of one or more classes without using inheritance.

But multiple inheritance has issues such as the Diamond Problem problem, and mixins can be a complex mechanism to work with. In this article I will discuss traits, a new feature introduced in PHP 5.4 to overcome such issues. What a Trait Looks Like A trait is similar to an abstract class which cannot be instantiated on its own (though more often it’s compared to an interface). Let’s consider this example: Reflection. L'URL Rewriting avec Apache, pour de belles adresses - Journal du Net Développeurs. Le serveur Web Apache propose un module d'URL Rewriting, qui permet de créer des adresses virtuelles afin de masquer les URL complexes des pages Web dynamiques.

L'utilisation des règles de réécriture d'URL permettent d'améliorer le référencement de vos pages par les moteurs de recherche ou encore la mémorisation par le visiteur, qui pourra comprendre plus facilement l'adresse. Le module URL Rewriting n'est pas activé par défaut avec Apache. Dans le cas d'un hébergement mutualisé, c'est le prestataire qui décide de sa disponibilité. Si au contraire, vous êtes maître de votre installation, vous pouvez vous en charger vous même. Installation du module La procédure d'installation et d'activation du module est assez semblable selon votre installation (système d'exploitation, paquets de la distribution ou compilation manuelle...).

Ces modifications s'appliquent dans le fichier de configuration d'Apache, généralement httpd.conf, ou apache*.conf (où * peut correspondre à la version installée). 1. Un site multilingue avec GetText. Google APIs Client Library for PHP (Beta) By Chirag Shah, Developer Programs Engineer Today we are announcing a major milestone for another one of the Google APIs client libraries. The Google APIs Client Library for PHP has officially reached Beta. This means we're comfortable enough with the stability and features of the library that we'd like you to start building real production applications on top of it and send us your feedback. The library now includes service-specific libraries and samples for several Google APIs, built on our new client library generation infrastructure.

The Google API PHP client supports the following Google APIs right now, with more on the way. Buzz API - SampleBooks API - SampleLatitude API - SamplePage Speed Online API - SampleTasks API - SampleURL Shortener API - SampleTo grab the latest version of the library, simply run the following commands: <? Let us know what you think. Since Google I/O 2010, we've been developing APIs that can provide descriptions of themselves via metadata. How to Automatically Linkify Text with PHP Regular Expressions. Good software enables us to take a lot of niceties for granted. Intelligent interfaces handle all the simple tasks so that we don’t need to worry about them. For example, when I type “www.desktopped.com” into an email or an instant message, I expect that it will be clickable on the other end without having to manually add in HTML tags.

Another example is parsing text from a twitter feed. For example, “@desktopped is a blog about the #computers“, we expect both @desktopped and #computers to be links. The ability to “linkify” text is a great tool to have when developing a blog or website. Possible uses include: Turning URLs clickable in content, comments, and anywhere elseTurning valid email addresses clickableTurning twitter text clickable so that @desktopped, #computers, www.desktopped.com all become links. How can we do this? Regular Expressions Basics A regular expression is a pattern string that represents a set of strings by using a variety of special characters.

A Simple Example Google+ Creating a Web Poll with PHP. Polls are nearly ubiquitous on the web today, and there are plenty of services that will provide a drop-in poll for you. But what if you want to write one yourself? This tutorial will take you through the steps to create a simple PHP-based poll, including database setup, vote processing, and displaying the poll. Step 1: Plan & Create the Database In order to store poll results, we're going to store three pieces of information: A question identifierAn answer identifierThe number of votes a question/answer pair has gotten For this tutorial, we'll be using PDO and SQLite. If you're working with SQLite3, you can create a new database via the command line tool; if you're using an older version, a quick PHP script will do the trick. This simple script will create a SQLite database in the directory you run it.

This creates a composite key for the database. Step 2: Design Your Poll's HTML Before you start writing any PHP, you need to decide how to create your poll in terms of markup. Poll View. 10 life-saving PHP snippets. Highlight specific words in a phrase Sometimes, for example, when displaying search results, it is a great idea to highlight specific words. This is exactly what the following function can do: Source: Get your average Feedburner subscribers Recently, Feedburner counts had lots of problems and it’s hard to say that the provided info is still relevant. Source: Automatic password creation Although I personally prefer leaving users to choose their password themselves, a client recently asked me to generate passwords automatically when a new account is created. Source: Compress multiple CSS files If you’re using different CSS files on your site, they might take quite long to load.

Header('Content-type: text/css'); ob_start("compress"); function compress($buffer) { /* remove comments */ $buffer = preg_replace('! DooPHP - Un framework PHP open source orienté performances et rapidité. Start. JqGrid is an Ajax-enabled JavaScript control that provides solutions for representing and manipulating tabular data on the web.

Since the grid is a client-side solution loading data dynamically through Ajax callbacks, it can be integrated with any server-side technology, including PHP, ASP, Java Servlets, JSP, ColdFusion, and Perl. jqGrid uses a jQuery Java Script Library and is written as plugin for that package. For more information on jQuery, please refer to the jQuery web site. jqGrid's Home page can be found here. Working examples of jqGrid, with explanations, can be found here. The last development version can be obtained from GitHub JqGrid was developed by Tony Tomov at Trirand Inc., a software development firm based in Sofia. Tony got the idea for jqGrid when he needed an easy way to represent database information in a project. Tony developed jqGrid and made it available for free as a way of making a contribution to the open-source community.

PHP And Me | Use Phing to update your SVN-version-controlled website automatically, through FTP. Protéger les images de son site web - Conseil #2. Deuxième billet de la série "Comment protéger les images de son site". Souvent la notion de copyright dépasse complètement la raison des internautes. Ils savent vaguement qu'elle existe, mais tout le monde "pique" des images sur Internet, donc pourquoi pas moi ?! Il est vrai qu'il est assez difficile de protéger réellement ses propres images sur Internet.

Même s'il n'existe pas de solution miracle, voici plusieurs conseils pour protéger vos images des pillards du web... Conseil n°1: Une image transparente superposée contre le click droit Vous l'avez sans doute déjà vu sur la Ferme du Web, les Watermark permettent d'ajouter un logo, un copyright directement sur une image pour éviter qu'elle soit réutilisée ou volée. Contrairement au conseil n°1, nous laissons la possibilité d'enregistrer l'image dans cette solution, mais avec notre marque ! Théorie Il y'a plusieurs types de watermark: Il existe différentes façons pour incruster un Watermark: Pratique Watermarking avec un service online Résultat: 1. Dropbox-php - Dropbox Client Library for PHP. Sauvegarde DropBox. Débuter avec Zend Framework 1.5 (approche MVC)

Ce cours est une introduction très sommaire au Zend Framework, dans le but d'écrire une application MVC très simple utilisant une base de données. Traduction de l'excellent tutoriel par Rob Allen : Getting started with the Zend Framework Tutoriel Zend Framework (tutoriel version 1.5.2). 23 commentaires Cet article est prévu pour la version 1.5 de Zend Framework, il n'explique pas les améliorations apportées à ce framework dans les versions plus récentes. Pour les versions ultérieures, merci de vous reporter à la traduction plus récente disponible ici : pour ZF 1.8 et 1.9 ou pour ZF 1.10 (article original ar Rob Allen, traduction par Sylvain Jorge Do Marco). Copyright © 2008 Developpez LLC.