php

When I announced this blog as a technology blog. And in order to pass a piece of programming, I just never have time. For this reason, I spent this time preparing a programming related material to make up for lost time. As for reviewing’m releasing at least one post a week, with tips php javascript jquery .. among others.

Well .. without further ado, let’s start .. the beginning.

What is PHP?

There has to be a story right .. but this will be my point of view.

For me, it is an extremely useful programming language, easy to learn and a lot of processing. That despite successful applications have not had an application that uses its maximum. And on the other hand, was used in negative ways, with various “hacks” with much spaghetti code, and many logic errors, which among other things, caused her a great reputation as unsafe.

What do I need to run php?

To run it, you need a web server as apache nginx , lighttpd. A connector, which will make this web server processes the PHP code. And the php package.

Do not know how to install the web server? You can check out some tips here:
http://viniciusmuniz.com/web-server/

PHP for beginners

PHP among its facilities, which are many. Can be mixed in half HTML of shell script … Not to get your started in PHP (“get your started” was good!), With the right foot. Try to separate the most of the php code from other technologies.

Example separated php code:

Obviously this is a pattern that I try to follow, but not necessarily be correct. The PHP does not obligate you in writing a standard code, such as Java, which can be a facility if you know how to use it, or a disaster if not.

Do not understand any of the above code right? Take it easy .. explain more below.

The server tells you that those lines are php? The delimiter “” ends.

As is common in most languages, the “;” concludes a command. For those who know c or c + + , will realize that there is a great similarity between these languages ??with PHP. This occurs because the php is written in C , and based on the same.

The PHP has many functions, and a great mix and the lack of standard arguments. To facilitate learning php. Always use the official website of php php.net . Use to find functions that do not know, like foreach simply login php.net / foreach

Foreach

As promised, the explanation of the code. The foreach is the simplest way to go a array , it is composed as follows, the first variable is the array to be traversed, and the second variable that will receive the data at each iteration of the [3×1001 ] foreach , can use the foreach iteration getting the key:

That way you can control which key, and make direct changes to the array traversed using is key in the proper array .

Until next time! In the next post, I will describe some ways to read and write files. Super simple shapes, the classic form of the inherited code in c. And the facilities of php.

Written by vinicius