Fiat Group SpA is a diversified global company in business for over a century and is one of the top fifteen automobile manufacturers in the world, even larger than Daimler AG. Producing more than 85% of the automobiles that the Fiat Group manufactures and sells, the Fiat Group Automobiles SpA (FGA) subsidiary produces about 1.98 million automobiles/year. Over 42,000 Fiat users channel over $30 Billion (USD) in revenue (24 billion euros) through their PHP-based Fiatlink system which is now the primary access point for all of FGA's dealers and service centers to enter car orders and access information across the Fiat Auto enterprise. This is business-critical PHP
“At the beginning we also considered Java as a development solution & language” says Roberto Fileni, Fiatlink’s Technical Architect, “but the main project goals were quick implementation and the PHP learning curve is much easier than with Java. In addition, Fiat Group’s IT division has a solid open-source technologies background. That also helped drive the choice for PHP.”
Conclusion given by FIAT LINK System
PHP is an ideal solution for large, modern enterprises looking to rapidly deploy new and added functionality for their users. Adopting an open-source solution like PHP strategically knowing that in addition to the vibrant open-source community, Zend Technologies is also standing behind the platform provides peace-of-mind when utilizing open-source technology with lower TCO. Supporting tools like the Zend Studio IDE, the Zend application server and more, plus global services consulting and training from Zend's professional services experts all add up to make PHP more than ready for enterprise solutions.
Fiat link is widely considered one of the most important PHP projects implemented to date in Italy and is considered a model for integrating heterogeneous applications and systems quickly and at a lower cost than competing solutions.
Thursday, January 29, 2009
Fiat Chooses PHP and Zend to build and web-enable their Fiatlink system
Tuesday, January 27, 2009
Understanding PHP error messages
Most important thing you need to know about before savoring the delights of PHP:
Error messages.
They’re an unfortunate fact of life, but it helps a great deal if you understand
what they’re trying to tell you. The following illustration shows the structure of a typical error message
Parse error: Syntax error, unexpected T_ECHO in c:\htdocs\testproject\test.php on line 15
Here
Parse error : resembles severity of error
unexpected : resembles what went wrong
File path : resembles where it went wrong
The first thing to realize about PHP error messages is that they report the line where PHP discovered a problem. Most newcomers—quite naturally—assume that’s where they’ve got to look for their mistake. Wrong . . . (Error messages
always prefix PHP elements with T_, which stands for token. Just ignore it.)
Instead of worrying what might be wrong with the echo command (probably nothing),
start working backward, looking for anything that might be missing. Usually, it’s a semicolon or closing quote on a previous line.
There are four main categories of error, presented here in descending order of importance:
Fatal error: Any XHTML output preceding the error will be displayed, but once the error is encountered—as the name suggests—everything else is killed stone dead. A fatal error is normally caused by referring to a nonexistent file or function.
Parse error: This means there’s a mistake in your code, such as mismatched quotes, or a missing semicolon or closing brace. Like a fatal error, it stops the script in its tracks and doesn’t even allow any XHTML output to be displayed.
Warning: This alerts you to a serious problem, such as a missing include file. However, the error is not serious enough to prevent the rest of the script from being executed.
Notice: This advises you about relatively minor issues, such as the use of deprecated code or a non declared variable. Although this type of error won’t stop your page from displaying (and you can turn off the display of notices), you should always try to eliminate them. Any error is a threat to your output.
There is a fifth type of error: strict, which was introduced in PHP 5.0.0, mainly for the benefit of advanced developers. Strict error messages warn you about the use of deprecated code or techniques that aren’t recommended.
Saturday, January 24, 2009
Server Information in PHP
In Php $_SERVER array contains a lot of useful informatiom from the webserver. For CGI specification infomation comes from the environment variables
Here is the list of entries in $_SERVER that comes from CGI
1. SERVER_SOFTWARE: A string that identifies the server.
2. SERVER_NAME: The host name, DNS alias, or IP Address for self referencing URL ex(www.php.com)
3. GATEWAY_INTERFACE: The version of the CGI standard being followed(e.g. CGI 1.1)
4. SERVER_PROTOCOL: The name and revision of the requested protocol(e.g. HTTP/1.1)
5. SERVER_PORT: The server port number to which the request was sent(e.g 80 or 85)
6. REQUEST_METHOD: The method the client used to fetch the document(e.g. GET)
7. PATH_INFO: Extra path elements given by the client(e.g. list/users)
8. PATH_TRANSLATED: The value of PATH_INFO, translated by the server into a filename (e.g home/httpd/htdocs/list/users)
9. SCRIPT_NAME: The URL Path of the current page, which is useful for self-referencing scripts (e.g /foldername/filename.php)
10. QUERY_STRING: Everything after the ? in the URL(e.g filename.php?filename=test)
11. REMOTE_ADDR: A string containg the IP address of the machine that requested this page (e.g 192.168.1.100)
Thursday, January 22, 2009
Including code from other files
The ability to include code from other files is a core part of PHP. All that’s necessary is to
use one of PHP’s include commands and tell the server where to find the file.
PHP has four commands that can be used to include code from an external file, namely:
include()
include_once()
require()
require_once()
They all do basically the same thing, so why have four?
include() is the only command you need. The fundamental difference is that
include() attempts to continue processing a script, even if the include file is missing,
whereas require() is used in the sense of mandatory: if the file is missing, the PHP
engine stops processing and throws a fatal error.
The purpose of include_once() and require_once() is to ensure that the external file doesn’t reset any variables that may have been assigned a new value elsewhere. Since you normally include an external file only once in a script, these commands are rarely necessary. However, using them does no harm.
PHP’s built-in superglobal arrays
The main superglobal arrays
$_POST: This contains values sent through the post method. where you'll use it to send the content of an online feedback form by email to your inbox.
$_GET: This contains values sent through a URL query string. You'll use it frequently to pass information to a database.
$_SERVER: This contains information stored by the web server, such as filename,
pathname, hostname, etc.
$_FILES: This contains details of file uploads
$_SESSION: This stores information that you want to preserve so that it's available to other pages. It's used to create a simple login system
Creating loops
As the name suggests, a loop is a section of code that is repeated over and over again until a certain condition is met. Loops are often controlled by setting a variable to count the number of iterations. By increasing the variable by one each time, the loop comes to a halt when the variable gets to a preset number. The other way loops are controlled is by running through each item of an array. When there are no more items to process, the loop stops. Loops frequently contain conditional statements, so although they’re very simple in structure,they can be used to create code that processes data in often sophisticated ways.
Loops using while and do... while
The simplest type of loop is called a while loop. Its basic structure looks like this:
while (condition is true) {
do something
}
The following code displays every number from 1 through 100 in a browser (you can test it in while.php in the download files for this chapter). It begins by setting a variable ($i)
to 1, and then using the variable as a counter to control the loop, as well as display the
current number onscreen.
$i = 1; // set counter
while ($i <= 100) {
echo "$i "; $i++; // increase counter by
1 } A variation of the while loop uses the keyword do and follows this basic pattern:
do { code to be executed }
while (condition to be tested);
The only difference between a do... while loop and a while loop is that the code within the do block is executed at least once, even if the condition is never true.
The following code (in dowhile.php) displays the value of $i once, even though it’s greater than the maximum expected.
$i = 1000;
do {
echo "$i ";
$i++; // increase counter by 1
} while ($i <= 100);
The danger with while and do... while loops is forgetting to set a condition that brings the loop to an end, or setting an impossible condition. When this happens, you create an infinite loop that either freezes your computer or causes the browser to crash.
The versatile for loop
The for loop is less prone to generating an infinite loop because you are required to declare all the conditions of the loop in the first line.
The for loop uses the following basic pattern:
for (initialize counter; test; increment)
{ code to be executed }
The following code does exactly the same as the previous while loop, displaying every number from 1 to 100 (see forloop.php):
for ($i = 1; $i <= 100; $i++)
{ echo "$i "; }
The three expressions inside the parentheses control the action of the loop (note that they are separated by semicolons, not commas):
The first expression shows the starting point. You can use any variable you like, but the convention is to use $i. When more than one counter is needed, $j and $k are frequently used.
The second expression is a test that determines whether the loop should continue to run. This can be a fixed number, a variable, or an expression that calculates a value.
The third expression shows the method of stepping through the loop. Most of the time, you will want to go through a loop one step at a time, so using the increment (++) or decrement (--) operator is convenient.
There is nothing stopping you from using bigger steps. For instance, replacing $i++ with $i+=10 in the previous example would display 1, 11, 21, 31, and so on.
Looping through arrays with foreach
The final type of loop in PHP is used exclusively with arrays. It takes two forms, both of which use temporary variables to handle each array element. If you only need to do something with the value of each array element, the foreach loop takes the following form:
foreach (array_name as temporary_variable) {
do something with temporary_variable
}
The following example loops through the $shoppingList array
and displays the name of each item, as shown in the screenshot
(see shopping_list.php):
$shoppingList = array('wine', 'fish', ➥
'bread', 'grapes', 'cheese');
foreach ($shoppingList as $item) {
echo $item.'
';
}
Although the preceding example uses an indexed array, you can also use it with an associative array. However, the alternative form of the foreach loop is of more use with associative arrays, because it gives access to both the key and value of each array element. It takes this slightly different form:
foreach (array_name as key_variable => value_variable) {
do something with key_variable and value_variable
}
This next example uses the $book associative array from the “Creating arrays” section earlier and incorporates the key and value of each element into a simple string, as shown in the screenshot (see book.php):
foreach ($book as $key => $value) {
echo "The value of $key is $value
";
}
Breaking out of a loop
To bring a loop prematurely to an end when a certain condition is met, insert the break keyword inside a conditional statement. As soon as the script encounters break, it exits the loop. To skip an iteration of the loop when a certain condition is met, use the continue keyword. Instead of exiting, it returns to the top of the loop and executes the next iteration.