Write PHP like JQuery

Posted: May 6, 2010

So I’ve certainly made my opinion of JQuery clear. As far as I’m concerned it’s really an integral part of the JavaScript language. The main thing it brings to the table is its drop-dead simple css-style selection and manipulation of the DOM.

However, another thing that many JQuery programmers really appreciate is the command chaining lets you pipe the object from one statement to another, futher shrinking the number of lines of code and in the process making it easy to just do a lot of different things in a row to one object.
Read the rest of this entry »

Introducing Conditionals

Posted: March 2, 2009

Conditionals basically allow you to tell PHP what to do, depending on certain conditions.  This is where you really start getting into PHP programming.  This is where you’ll find the ‘If…Then’ you may have seen before in programming.

Conditionals aren’t too hard.  The most basic form of a conditional is the ‘If’ statement.

If something is true…
Then do something else
Read the rest of this entry »

Simple Math with PHP

Posted: February 28, 2009

PHP has built-in math functionality for most of your mathematical desires.  Here are a few of the common math operators and what they do:

+      adds numbers
-    subtracts
*    multiplies
/    divides
%    modulus (the remainder of a division)
Read the rest of this entry »

More Fun with PHP Strings

Posted: February 27, 2009

PHP is a pretty good language to work with text.  Some programming languages have separate types for single characters (chars) and strings.  With PHP it’s pretty much all the same.  Some languages (I’m looking at you C!) don’t allow strings at all, and only have characters.  So, with as much as PHP keeps out of your way, strings aren’t that bad. Read the rest of this entry »

PHP Datatypes

Posted: February 24, 2009

Programming languages all support different types of data, such as numbers or text.  But to the programming language, it gets even more specific.  There are many different kinds of numbers, for example, depending on whether it has a decimal or not.

Some common datatypes:
int  – an integer, or whole number without a decimal
float – floating point numbers, basically a number with a decimal
double – same as a float, but more specific.  It can hold longer values and more decimal places
bool – Boolean values.  Basically true or false
string – strings of text
array – a special type of variable which can hold a whole set of other variables inside it. Read the rest of this entry »

Forms + PHP = BFF

Posted: February 20, 2009

One great way to use PHP is to use web forms to get data from visitors to your site. You’re all probably familiar with the standard HTML forms:
<form method=“post” action=“page.php”>
Please enter your name: <input type=“text” name=“username” />
<input type=“submit” value=“Send” />
</form>

See those extra attributes in the form tag, method and action? Those are how you can send things to a PHP script on another page.

Read the rest of this entry »

PHP Variables

Posted: January 29, 2009

Variables? Like algebra?
Yep. Like algebra.

Just like in algebra, variables in PHP will substitute for a value. But a variable in programming is different from in math, because a variable doesn’t just stand for numbers. You can use a variable to stand for just about everything from numbers, to characters of the alphabet, strings of text, entire sets of different values, even other variables!
Read the rest of this entry »

What is PHP?

Posted: January 27, 2009

PHP is a server-side, interpreted scripting language.

What does that mean? Well server-side means it runs the code on the web server, so your users don’t download the code and run it in their browser, like with JavaScript. This means that you’re not making your visitor’s computer do all the work, and it also means that your code is more secure, because your visitors don’t ever see the actual code, only what you send to their browser.

Interpreted means that it doesn’t have to be compiled into a program, like a windows .exe file, to run, but the web server interprets the code live as it comes to it.

A scripting language is really basically a ‘lite’ programming language.
Read the rest of this entry »

Learning PHP

Posted: January 25, 2009

A lot of people around me have had questions about PHP lately.  Seems like I’ve been doing a lot of PHP training.  So I decided to begin posting PHP lessons for the beginner with no programming experience.  I’m basically assuming no experience with writing functions, variables, or anything else that a lot of training takes for granted.  All you’ll need to learn PHP is to have a familiarity with proper XHTML and CSS, though again you don’t need to be a super CSS guru supreme.

My next post will contain the first lesson, which will really be more of an introduction to PHP.