News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

PHP Manual Masterpieces:
I Can't Spell PBKDF
November 13, 2013 @ 09:58:08

On the PHP Manual Masterpieces site has a recent post looking at PBKDF and PHP (and, more specifically, the information that's presented about it in the manual).

So why are we here? Well, a faithful follower slipped me a tip to check out the documentation. It turned out I agreed: I don't like it. [...] Let's be clear: I have read the backing C code of this feature and I see nothing wrong with the actual functionality. My issues are strictly with the documentation and the API, both of which are very PHP-ish in the sorts of ways that drive me to hateblog about a programming language on a Friday night. It turns out there are people who are totally okay with these design decisions, and I can't help that their subjective tastes are wrong, but that's just how it is.

She mentions three different major issues with the documentation currently in the manual:

  • Non-copypaste-safe cryptography
  • The fact that PHP does not fail effectively when it comes to cryptographic handling
  • The lack of units defined (like for the "length" parameter of hash_pbkdf2)
0 comments voice your opinion now!
pbkdf cryptography manual examples error failure units

Link: http://phpmanualmasterpieces.tumblr.com/post/66426423275/i-cant-spell-pbkdf

Reddit.com:
Worst practices
September 04, 2013 @ 11:35:52

In this recent post to Reddit.com, people have been sharing some of the "worst practices" they've seen during their PHP development (or may even be guilty of).

For shits and giggles some colleagues and I are trying to write the crappiest PHP script we can think of, using as many bad practices as we can find. Alas, it's much harder then we thought, because we all have been trained to not do stupid stuff.

Things on the list so far include:

  • Multiple class definitions in a single file
  • Saving passwords unhashed and unencrypted in a database
  • Using a global variable inside a class to get a database connection
  • One letter variables
  • Pointlessly setting the signup method to being static
  • Using GET or POST vars directly from user input
  • Mixing HTML and PHP like there's no tomorrow.
  • make liberal use of extract() after running 'SELECT *'
  • Define a custom exception class for each class and only throw it from that class.
  • Make sure your DB connection is a singleton.
  • Throw ugly constants everywhere

What are some of the worst things you've seen? Share them here.

0 comments voice your opinion now!
worst practices opinion examples list

Link: http://www.reddit.com/r/PHP/comments/1lpgqk/worst_practices

Script-Tutorials.com:
Functional Programming - How to Write Functional Code in PHP
May 09, 2013 @ 11:04:26

On the Script-Tutorial.com site today there's a new post looking at functional programming in PHP - some of the concepts involved and example code showing how to make it work.

Functional programming can be defined in simple terms as a programming paradigm that do not change the state of a program instead it uses pure functions. A pure function is a function that has the ability to accept a value and return another value without changing the input supplied to it. It is characterized by its ability to support functions that are of high order. [...] A programming paradigm that is functional has the following attributes: do not alter the states which make parallelism easier, deals mostly with a function which is the smallest unit hence enhances readability of code, has deterministic functions that enable stability of a program.

He talks some about anonymous/lambda functions (closures) and their role in PHP's implementation of functional programming. He also talks some about partial functions, currying, higher order functions and recursion. He finishes off the article with a look at some of the advantages this method of development can bring as well as some of the disadvantages that come with things like recursion and the learning curve of the method.

0 comments voice your opinion now!
functional programming tutorial introduction concepts examples

Link: http://www.script-tutorials.com/functional-programming-php

Francois Zaninotto:
Node.js for PHP Developers Series
January 23, 2013 @ 09:21:48

If you're a PHP developer and have ever wanted to branch out into learning another language, Node.js is a popular choice right now. To help you ease into some of the concepts that Node development involves, Francois Zaninotto has come up with his "Node.js for PHP Developers" series of posts (4 of them now, one previously mentioned here):

in each article he provides code examples showing "the Node way" versus "the PHP way" to do various things. It's a great little series and can definitely kickstart your Node.js knowledge.

0 comments voice your opinion now!
nodejs developer tutorial series examples code


NetTuts.com:
Namespacing in PHP
October 02, 2012 @ 13:48:00

On NetTuts.com today there's a new tutorial introducing you to namespaces in PHP and a complete guide to the features that come with them.

It's been a bumpy ride, in regards to namespace support in PHP. Thankfully, it was added to the language in PHP 5.3, and the applicable structure of PHP code has improved greatly since then. But how exactly do we use them?

They start with a definition of a namespace (for those unfamiliar with the term) and get right into the code showing their use in PHP:

  • Defining a Namespace (and Sub-namespaces)
  • Calling Code from a Namespace (using Unqualified/Qualified/Fully Qualified names)
  • Dynamic calls
  • The namespace Keyword
  • Aliasing or Importing
0 comments voice your opinion now!
namespace tutorial introduction features examples


JellyandCustard.com:
Regular Expressions in PHP
June 22, 2006 @ 07:03:06

In a post from JellyandCustard.com, there's an inside look at regular expressions in PHP - how to use them and what they are.

Regular Expressions (regex for short) appear to a lot of people as the 'black art' of coding. Most languages, be it PHP, Java, C, .NET, VB etc have a way of using regular expressions - and they can certainly make your job easier. So lets start on our journey into regular expressions. I am by no means an expert, but hopefully I'll be able to clear the fog that surrounds regular expressions!

He mentions the functions to use and provides a simple example of matching a phone number (US format). They take the regular expression string and break it down into its pieces, explaining how each one works (and relates to the other parts of the expression). They also provide a brief "cheat sheet" of some of the other special characters (including common uses on some).

0 comments voice your opinion now!
regular expression introduction tutorial functions examples regular expression introduction tutorial functions examples


SnippetCollection.com:
PHP Snippets & Examples
February 14, 2006 @ 07:09:05

Welcome to SnippetCollection.com. Here you can find a large collection of snippets and examples in ActionScript, Php, Java, Java Script, VB, VB.NET, C, C++, ASP, ASP.NET, Perl , SQL and Python.

SnippetCollection.com is just like it sounds - a resource for sharing those little handy pieces of code that we all use over and over again. There are various other categories, but the PHP section has its fair share of items in the list. Various topics and skill levels are represented here, everything from "calling a function" to advanced array operations. So, if you have a bit of code to share with the world, head over, sign up, and get started...

2 comments voice your opinion now!
snippets examples share snippets examples share



Community Events





Don't see your event here?
Let us know!


tips podcast library opinion release zendserver bugfix language introduction community update api symfony interview install deployment framework laravel package series

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework