background preloader


Facebook Twitter


Engine. String. Restful. Opensource. Utilisation avancée de file_get_contents (PHP)  Préambule Je fais cette note technique car je me suis plus d’une fois confronté à différentes configurations pour accéder à une page Web à partir de PHP.

Utilisation avancée de file_get_contents (PHP) 

Normalement un serveur Web dispose d’une connection directe à internet et n’a pas besoin d’un proxy pour y acceder. Mais si on fait des script PHP en CLI (non liès à un serveur Web) on peut se trouver confronter à différents problèmes… Cas 1 : la simplicité même Voici le cas le plus simple pour récupérer un page à partir de son URL. Si il vous manque l’extension open_ssl vous aurez une erreur dans ce genre : Notice: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? C’est aussi valable pour les cas suivants. Cas 2 : Authentification HTML Si la page est protégée par un mot de passe, PHP peut transformer une URL avec utilisateur et mot de passe pour envoyer la requête avec les bons headers. Méthode alternative Source : Cas 3 : En passant par un proxy HTTP ou HTTPS. Tutoriel complet sur les redirections (301, 302, JavaScript, …)

Il arrive fréquemment que, sur un site web, des pages web disparaissent ou changent d'adresse.

Tutoriel complet sur les redirections (301, 302, JavaScript, …)

Lorsque cela arrive, il est nécessaire d'en aviser les moteurs afin de leur indiquer la marche à suivre et notamment leur soumettre la nouvelle adresse d'une page déjà référencée (et parfois bien positionnée). Loading page title.. Ed's recent blog post labeled the The MicroPHP Manifesto got a lot of attention.

Loading page title..

Personally I feel like Ed's way of expressing himself feels mostly like the rants of an angry person and not really a way of expressing a clear message. That is why I appreciate a much saner formulated follow up by Kris Jordan. In general I totally agree with Ed on the point that we need more decoupled components in the PHP world. The timing seems a bit odd since exactly that seems to be an emerging trend with all the various libraries cropping up since PHP 5.3. PHP Page basic page caching. One of the most useful things you can do in terms of performance is to cache the page you’re currently serving so that no code gets executed again and again when it isn’t needed.

PHP Page basic page caching

I’ve provided a sample below of how you can set-up quick and dirty page caching by including template files in your code. Cache Class Save the following into cache.php. The above class implements three functions, load() errors() and stats() – The load function should have one parameter passed into it, which is the name of the template you wish to load. The errors() returns an Array of any errors that the class encountered (only implemented in the load function for now) and stats() prints a table of cache statistics. Memento des expressions régulières. GeSHi - Generic Syntax Highlighter. Latest News GeSHi on GitHub You can find more details on this change in my blog.

GeSHi - Generic Syntax Highlighter

GeSHi Website available encrypted 2012/11/25 I recently decided to make the GeSHi website available via SSL as a related project requires use of SSL anyway. Currently I'm not yet forcing SSL, but if you connected successfully via SSL once you'll use it automatically for the next six months due to HSTS. The reason I'm currently not enforcing is that as the used Certification Authority CAcert is not in the trusted store of Mozilla and Internet Explorer (although the second is not relevant to me) you'd probably get alot of confusing warnings. This change is available for and GeSHi Released 2012/08/19 Again quite some time has passed but here it is: the new release of GeSHi with loads of new languages, some minor parser tweaks and fixes to existing language files.

More information on current GeSHi developement can be found in the GeSHi corner of my blog. BenBE. Credit Card PHP Validation Script. This PHP function checks the validity of a credit card specified by the supplied parameters containing the card number and card type.

Credit Card PHP Validation Script

The specifications for valid credit cards have been taken from various sources on the web. The commonest credit cards are are supported in this implementation, but more may be added as required. One of the advantages of this routine is the ease with which additional cards may be added, as it is totally data driven. Try the routine. Although no attempt is made to capture the input, it is suggested that you don't provide the number of your own credit card. The function returns true or false, depending on whether the credit card name / number combination is found to be valid. The credit card details are held in an array within the function, and additional cards may be readily added. PDO : Interface d'accès aux BDD. Error Handling in PHP » phpmaster. Errors are the most common event a developer faces when programming.

Error Handling in PHP » phpmaster

Page 6 - Using SOAP with PHP. (Page 6 of 7 ) Creating a SOAP Client to access our Server with is just as simple as creating the Server was.

Page 6 - Using SOAP with PHP

Understand though that the Client does not necessarily need to be a PHP Client. The SOAP Server we just created can be connected to by any type of Client, whether that be Java, C#, C++, etc. To create the SOAP Client, all we need to do are three things. First, include the NuSOAP library. Secondly, we need to instantiate the soapclient class. Last make a call to the Web Service. PHP Help, PHP Tutorials, Object-Oriented PHP5 Programming - Dev Shed.