News Feed
Jobs Feed
Sections




News Archive
feed this:

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

SitePoint PHP Blog:
Implementing Multi-Language Support
April 16, 2014 @ 12:18:39

The SitePoint PHP blog has a new post from Jacek Barecki talking about a few ways you can include multi-language support in your PHP applications. There's not much in the way of actual code here, but there are links to some other tools that can help get the job done.

Setting up a multilingual site may be a good way to attract new customers to your business or gain more participants in your project. Translating a simple site with a few static pages probably won't probably be complicated, but more complex PHP web applications may require a lot of work when launching multiple language support. In this article I'll present different types of content that need to be taken under consideration when internationalizing a site.

He breaks it down into five different types of content that you might want to translate:

  • Multi-language Static Content
  • Database content
  • User submitted content
  • Resources (images, videos, etc)
  • Other types of content

He wraps it up with a few recommendations including making a checklist of the things you want to translate to figure out what tools you need to use.

0 comments voice your opinion now!
multilanguage support implementation content type

Link: http://www.sitepoint.com/implementing-multi-language-support/

Nikita Popov:
Methods on primitive types in PHP
March 17, 2014 @ 12:11:22

In his latest post Nikita Popov highlights one of the topics from this post, primitive types as objects, and some alternative options.

A few days ago Anthony Ferrara wrote down some thoughts on the future of PHP. I concur with most of his opinions, but not all of them. In this post I'll focus on one particular aspect: Turning primitive types like strings or arrays into "pseudo-objects" by allowing to perform method calls on them. [...] Note that this isn't far off dreaming, but something that already exists right now. The scalar objects PHP extension allows you to define methods for the primitive PHP types. The introduction of method-call support for primitive types comes with a number of advantages.

Among the advantages he lists:

  • The opportunity for a cleaner API (instead of the current, sometimes oddly named functions)
  • Improved readability
  • Polymorphism through a "cleaning up" of shared methods
  • Loose Typing

He also looks at possible ways that other primitive types could be handled (like "null" or "float") and some of the problems that could come up when passing objects around. Since the values could be an object or scalar, how would you know the difference. He finishes off the post with a look at the current state of things, including that there's not much resistance just that there hasn't been a good API defined to make it work.

0 comments voice your opinion now!
method primitive type object example problems

Link: http://nikic.github.io/2014/03/14/Methods-on-primitive-types-in-PHP.html

SitePoint PHP Blog:
HHVM and Hack - Can We Expect Them to Replace PHP?
February 13, 2014 @ 09:29:39

The SitePoint PHP blog has a new post today that asks can we expect HACK and HHVM to replace PHP as an evolution of the PHP language and interpreter.

HHVM is intended to achieve both parity with the Zend Engine features and best possible performances. Facebook claims a 3x to 10x speed boost and 1/2 memory footprint by switching from PHP+APC to HHVM. Of course this is really application dependent (10x being for the FB code base). [...] Instead this article will focus on HACK which is an evolution of the PHP language designed to be safer, to enable better performance and to improve developer efficiency.

He starts off by helping you get an instance of HHVM up and running (via Vagrant) and create a simple HACK script. From there he gets into some of the more advanced HACK features like constructor argument promotion and collections. The talks some about typing, type hinting and the use of generics as well.

0 comments voice your opinion now!
hack hhvm facebook introduction tutorial type collection constructor

Link: http://www.sitepoint.com/hhvm-hack-part-1/

Samantha Quinones:
Juggle Chainsaws, Not Types
November 22, 2013 @ 09:25:33

Samantha Quinones has a new post today about something that has been known to trip up both new and experienced PHP developers - PHP's dynamic type juggling.

No matter how popular an activity it is, I really don't like to bash on PHP. Every language has its flaws when you look closely enough, and if PHP wears its idiosyncrasies a little closer to the surface than most, I think it makes up for it in other ways. PHP's handling of types, however, is confusing at best and at worst completely deranged.

She goes on to talk about the issues with type comparisons and how much trouble using the "==" (double equals) versus the "===" (triple equals) can potentially cause. While it's easier for new PHP developers to get caught by this issue, even experienced devs might miss it. She gives an example of a time in her own development involving the comparison of strings against constants and in_array's non-string type comparisons.

0 comments voice your opinion now!
type juggling strict loose comparison inarray

Link: http://www.tembies.com/2013/11/juggle-chainsaws/

PHPMaster.com:
An Introduction to Ctype Functions
April 30, 2013 @ 11:38:32

On PHPMaster.com today David Shirey has a written up a new tutorial introducing the ctype functions in PHP. This set of functions provides a handy way to more correctly check values to ensure they're valid (and contain what they should).

If you have a background in C, then you're probably already familiar with the character type functions because that is where they come from (don't forget that PHP is actually written in C). But if you're into Python, then it's only fair to point out that the PHP Ctype functions have absolutely nothing to do with the Python's ctypes library. It's just one of those tragic and totally unavoidable naming similarities.

He briefly explains how the functions work and at least one "gotcha" to watch out for if you're using them for input validation. He then goes through the list of the eleven ctype functions and briefly describes what they do. Some example code is also included showing how you can use them to validate a value based on the true/false return from the function call.

0 comments voice your opinion now!
ctype function introduction tutorial character type

Link: http://phpmaster.com/an-introduction-to-ctype-functions

Phil Sturgeon:
Understanding Circumstance
August 22, 2012 @ 10:15:08

Phil Sturgeon has a new post to his site today comparing a few different types of developers and discussing language/tool zealots among them (and a plea for tolerance and understanding).

What is it you do as a developer? As I see it in web dev there are a few different types: Hobbiest, Client Web Dev, Distributed Application Devs, Web App Developer (SaaS) and Corporate Dev. What do they all have in common? They're all using some sort of language to make some sort of system for somebody somewhere. That is about the last connecting factor that most of us developers actually share. [...] The crazy thing here is that most developers who are in a situation where they can use whatever system they like, often end up picking a specific tool and using it to death. This is ridiculous, as every developer should use the best tool for the job.

He talks a bit about each of the different categories of developers and where he sees their place in the world of development. He points out some of the restrictions of each type of position (required technologies, dependencies, etc) and comes to his point about their choices:

The point I am trying to make in all of this, is that while you might have really strong opinions about what language, framework, version of the framework or version of the language you use, EVERYONE has a totally different situation to you.
0 comments voice your opinion now!
opinion developer type restriction technology choice


DZone.com:
The Best Unknown Databases for PHP Apps
August 06, 2012 @ 10:49:50

In this new post to DZone.com today Leigh Shevchik kicks off a series of posts looking at the "unknown databases" that PHP developers might not think about when working on their applications.

In this day and age, there a plethora of options available to us. In this three part series, I'm going to walk you through five alternative databases that you may or may not have heard of. [...] Whether you're involved in embedded development, OLTP, OLAP, massive scalability and storage or simple database-backed applications, you're not going to walk away with the same perspective that you had before you started reading these posts. So without further ado, let's get started with a look at a veteran of the Internet: Berkeley DB.

She covers some of the database's basic features and a bit about its history (available for years) as well as some detail on how requests to the database work. To make the connection from your application, you'll need to install the dba PHP extension. She provides two examples of code that uses the database - one that just connects and deletes a record, another that adds/removes/finds users from an "address book" database.

0 comments voice your opinion now!
database type unknown berkeleydb tutorial dba extension


Community News:
PHP Benchmarks Compared to Several Languages
July 25, 2012 @ 09:14:41

Ariz Jacinto has pointed out some results from a recent benchmarking "game" that compares the performance of several languages against each other in overall speed.

Here's the link to the Computer Language Benchmark Game as of July 15, 2012. You'll see that the median speed of PHP is slightly faster than Python 3 and Ruby 1.9 on x64 Ubuntu/IntelQ6600 Quad-core machine.

You can visit the results page and turn on and off various languages to get the updated results in the chart. You can also limit it down to one of the many benchmarking test types as well.

0 comments voice your opinion now!
benchmark language multiple type chart performance


John Sonmez's Blog:
Types of Duplication in Code
May 29, 2012 @ 13:58:03

On his "Simple Programmer" blog John Sonmez has a new post looking at three kinds of "code duplication" that you should keep an eye out for when coding your applications:

One of the biggest reasons to refactor code is to eliminate duplication. It is pretty easy to introduce duplication in our code either unintentionally or because we don't know how to prevent or get rid of it. [...] I've found that there are three basic types of duplication that we can eliminate from our code that successfully build on each other.

He describes the three types - data, type and algorithm - and gives some code snippets showing how they present themselves and simple solutions of how to resolve them. There's also a quick mention of a "combined attack" when more than one form of duplication shows up at once. He suggests a to help find the "edges" of the duplication:

I've also found the key to eliminating duplication is sometimes to first exaggerate it. Often I will purposely take two methods that I know have some duplication and make them look even more duplicated in order to be able to clearly see where the duplication lies.
0 comments voice your opinion now!
code duplication data type algorithm


Anthony Ferrara's Blog:
PHP's Source Code For PHP Developers - Part 3 - Variables
March 22, 2012 @ 08:30:45

The third part of the "PHP source for developers" series has been posted over on Anthony Ferrara's blog today looking at the variables PHP's internals use.

In this third post of the PHP's Source Code for PHP Developers series, we're going to expand on the prior posts to help understand how PHP works internally. In the first post of the series, we looked at how to view PHP's source code, how it's structured as well as some basic C pointers for PHP developers. The second post introduced functions into the mix. This time around, we're going to dive into one of the most useful structures in PHP: variables.

He starts with one of the most important variable types used in PHP's source - the ZVAL. This is one of the keys to PHP's loose typing and can be thought of as "a class with only public properties". He gets into more detail with the properties of this "class" (value, refcount__gc, type and is_ref__gc). Also included is a look at how it's actually used - creating new ones, getting the value of them, converting their types and how the internal PHP functions parse their variables.

There's a lot more covered about variables in the post so if this is interesting stuff to you, be sure to read it all. They've done a great job of explaining one of the more complicated parts of the internals that power PHP.

0 comments voice your opinion now!
source code internals language variables parse type zval



Community Events











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


facebook hhvm introduction performance component series composer unittest symfony2 opinion framework application security package install release language hack podcast code

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