PHP Programming 101

February 26th, 2015

Embedding Comments

Posted by Conrad in Basic Programming, Sample Code

Now, to make you a better programmer we all know the value of comments. This allows you to understand the code that you have written defining and given meaning to operations as you build them up. You start with the terminators used by PHP and end with them as well. Single line comments look like this �// comment� and Multi-line ones use the syntax /* comment comment*/. A better example would be the one below:

//comment
/* comment
Comment*/
?>

In the next post we take on the best parts of PHP which would be variables which is essential in all programming languages.

February 19th, 2015

More Programming Basics

Posted by Conrad in Basic Programming

As with all programming languages PHP has different variable types such as numeric, character, string and Boolean types. Boolean variables in PHP always return either true or false, integers are whole numbers, floating points are decimal or scientifically notated and strings are a chain of characters. Sounds familiar, well they are and they are mostly standard across the various programming languages. For a more in-depth discussion on the different data types of PHP go visit the manual page.
We next discuss operators such as the assignment operator which allows you to assign values to variables allowing complex operations to be constructed into more and more functional programs.

February 12th, 2015

6 Tips For Better Form Design (2/3)

Posted by binary in PHP

ERROR HANDLING
When there is an error within a field, always put a notice next to it and a message at the top indicating the user about the error – if you don’t put the message at the top, people will not notice that there is an error, and if you don’t put a notice near the problem field, people might not tell it from the others.


MARKING NECESSARY FIELDS

Always mark required fields – either with bold text, or, more commonly, an asterisk *. This is to make the users aware that the essential fields must first be satisfied before proceeding to the next step.

To be continued…

February 5th, 2015

SERVER REVIEW: APACHE vs. IIS

Posted by binary in PHP

Apache is an open source http server named after the Native American. It is then first release in the year 1995. Now a day, Apache is considered as the most used http server in the world. It is compatible with almost all operating systems like Linux, Windows, Mac and etc. Almost anyone can adopt with this http server because of its source code is freely available. The Apache 2.0 which comes with a new Windows optimization technology called the Apache Portable Runtime (APR) while previous Apache version were not optimized for Windows. Apache developers can use Java, Perl and PHP on a .Net platform.

to be continued…

4229-apache-server.jpg

Image Source: www.pdftown.com

January 29th, 2015

Array Chunk Function

Posted by Conrad in Basic Programming, Sample Code

The array_chunk() function on the on the other hand as the name implies, divides an array into chunks or several tables from the source table. The syntax goes something like array_chunk(array,size,preserve_key), wherein the array is the table that would be divided, the size is the number of elements which the new arrays are to contain and the preserve key which can either be true or false is used to either retain or revise the key or pointer value of the original table. An example is shown below:

$a=array(�a�=>�Cat�, �b�=>�Dog�, �c�=>�Horse�,�d�=>�Cow�);
print_r(array_chunk($a,2);
?>

The code would have an output of:

Array (
[0] => Array ( [0] = > Cat [1] => Dog )
[1] => Array ( [0] => Horse [1] => Cow )
)

As we can see, the original array has been divided into two arrays array0 and array1 and a value that is not given for the key had it assigned a new key for each of the tables. Another example would be :

$a=array(�a�=>�Cat�, �b�=>�Dog�, �c�=>�Horse�,�d�=>�Cow�);
print_r(array_chunk($a,2,true);
?>

This would then give us ;
Array (
[0] => Array ( [a] = > Cat [b] => Dog )
[1] => Array ( [c] => Horse [d] => Cow )
)

This shows the significance of the retain key field wherein the two new arrays retained their original keys. The reverse of which would be the array_combine() which divided the array into one which holds the keys and one with the values.

January 22nd, 2015

PHP to Get it’s own Stack

Posted by Conrad in Information

zendPHP is the most popular programming platform to ever grace the web and thanks to PHP, most of today’s web sites, blogs and many other internet staples are made possible with the use of PHP. Now one of the best news to come out of the PHP world is the announcement of the development of the Zend Server which would allow web application deployment and monitoring easy. This has been the most welcome news for till this, most systems have had to rely on the long used LAMP standard that worked but still relied on more traditional development methods that were labor intensive and quite hard to troubleshoot.
Zend promises to deliver faster development, deployment and bug fixing capabilities we can only dream of. (more…)

January 15th, 2015

Working with variables: isset(), empty(), and unset()

Posted by Conrad in Basic Programming, PHP


bool isset ( mixed var [, mixed var [, mixed ...]])
void unset ( mixed var [, mixed var [, mixed ...]])
bool empty ( mixed var)

There are three very basic functions that help you use variables, and these are isset(), empty(), and unset(). Isset() and empty() are almost opposites, but not quite – isset() will return true if a variable, passed in as its only parameter, has been set in the script already, whereas empty(), which also takes a variable as its sole parameter, will return true if the variable has a false value. This is not the same thing!

To illustrate the difference consider the variable $foo being set to false – isset() would return true because $foo is a variable that has a value, and empty() would also return true because $foo’s value is false. To check for “variable not set”, use the not operator !, as in “if (!isset($foo)”.

Unset() removes an existing variable entirely, so that isset() will return false. That variable can be recreated later on in the script, however. Use unset() when you want to delete a variable.

Source

January 8th, 2015

Understanding Cookies

Posted by Edi in Information

Photobucket

What exactly is a cookie? It’s not a food, in the computer world, a cookie is a small amount of information sent by a Web server to a web browser. They are sent back unchanged by the browser each time it accesses that server. They are used for tracking, storing, authenticating information regarding the users which include sites visited. They give capabilities that make the web easier to navigate. If you are using Microsoft’s Internet Explorer to browse, you can see all of the cookies that are stored on your machine. They are usually stored in a directory called c:\windows\cookies.

It is composed of a cookie name and cookie value. The setcookie function() can be used to send a cookie to a browser to request your PHP page.

January 1st, 2015

More into the syntax of PHP

Posted by Conrad in Basic Programming, Sample Code

As you might have seen, all of the PHP statement ends with “;” which would be somewhat similar to Perl. The valid HTML code that was handed back to the server was :
Sample:
html>
head>
body>
Who are You?
br />
My name is MacGyver.
/body>
/html>
(Note: opening “<” were removed to allow display of the code)
More in the coming posts when we dig deeper as we widen our understanding of PHP.

December 25th, 2014

Php? How does it work?

Posted by Conrad in Information


Image Source:technical-itch.co.uk

What are the uses of Php in the whole computing thing? We might wonder. The answer is simple. Php is practically used everywhere. It is being adapted to multiple platforms. The scripting language has revolutionized the way we communicate within the internet. Php reads and writes files. It is used to execute basic directory and file monitoring and maintenance. Simply put, Php has enabled developers and programmers and users to do things that wasnt possible to do in the web the previous years, like editing specific documents and files remotely. It is used to search files. Collect them and for the information stored in that file to remain there and retrieve it when needed. Now, information is more accessible. It does not require to be coded to a certain database. It can generate HTML and PDF files. It can process XML for HTTP. Its amazing capability to function on different data source makes it the idela tool for search engines.

Next Page »