Tag: php

PHP Lessons Part 2: Operators

by
Guest-GS

Welcome to Part 2 of the PHP lessons.

In the previous lesson, we talked about how to get started with PHP, setting up a local environment to develop in PHP. We also talked about Variables and how they can be very useful when developing.

Just to refresh yourself up, the way we write a variable is like so:


$myVariable = "This is some fancy text";
echo $myVariable;
?>

Continue Reading »

PHP Lessons Part 1: Introduction to PHP and Variables

by
Guest-GS

What is php?

PHP is a powerful programming language for programmers to add interactivity to web pages, making them dynamic. What does “dynamic” mean? Simply “not static”! It may seem strange, but this is exactly what it is. Traditionally, web pages were “static”, coded in HTML. Nowadays, these pages are filled contents that change over time. Think about a blog. Aren’t new articles added from time to time? Well in the past, someone had to go edit a webpage, add code and add the article there manually. Nowadays, the article is pulled from a database, and dynamically added to a page as it is posted. That’s what PHP does: generating pages on the fly with content, with the help of HTML and other languages of course.

PHP is free (as in no cash needed, and open source – you can download and view the PHP source code) and is among the most popular programming languages used for Website Developement, to do processing.

What does PHP stands for?

PHP means: Hypertext Pre-Processor (HP, right? It’s a recursive acronym! It originally meant, Personal Home Page). It is a server side language and are executed on a server (Not on a local machine like Javascript, HTML and CSS). PHP can interact with Many databases out there such as MySql, Oracle, etc. To fully make use of PHP, a minimum knowledge of HTML is required, as well as some basic CSS if you wish to make things look nicer, but CSS is not directly required.

Continue Reading »

PHP – The Basics of the Language

by
Guru

Today I will be talking  a bit on PHP’s syntax and constructs. Previously I had given a small introduction on PHP. Now is the time to get your feet wet. Before going even further you should have PHP and MYSQL minimally running on your machine a.k.a localhost (You can go for an elaborate discussion on localhost at wikipedia or stick to my simple description. Refers to your own machine also addressed by 127.0.0.1).  I know you are a Geek, you may want to do your own setup but yet, I would recommend you to take a look at integrated packages such as:

  1. Xampp (my preference)
  2. Wamp
  3. EasyPHP

As far as I know personally I have heard of these three packages. There are more out there in the wild. Xampp would be enough for all your development tasks. Please bear in mind these packages are meant only for development purposes. They are not to be used on a live website.

Continuing where I left. Lets talk syntax. uhh, let me remind you coding scripting in PHP is very different from conventional programming. As I say often, PHP has a philosophy, a way of getting things done. 🙂 Don’t be afraid.

Continue Reading »

PHP – An Overview

by
Guru

PHP has been going strong since its very first public release. Today it is among the leading scripting language powering the web; think Google, YouTube, Digg and the likes. You might and might not have got the feeling of dynamism after I have mentioned the previous websites. Yes, you make the ground move. You can turn your old static page into a living one (dynamic), well I am talking about PHP right now. I am not going to bias you into thinking that we have got only PHP for this particular need; we have got asp .net as an example.

PHP is still a young language under under heavy development, with its developers writing and rewriting its core, improving it with each new release. You must be at least aware that we are in the object oriented generation. As from version 4, PHP has object oriented available for you to play with. With now its 5 series it has improved object oriented, but cannot be compared with Java and C++ language object orientation. Yet, it is sufficient for us to write beautifully.

I will now try build up your thinking stream; how you should do it in PHP. 🙂

PHP can be embedded anywhere in HTML. For instance we can display a simple text using PHP and html. Before going any further, PHP is used for its logical potential as compareds as the HTML counter part which offers us only the “displaying” ability. PHP does all the processing and its end product is some “HTML” that you will use for displaying. I am sure you must have this part right in your head.

<html>
<head>
<title>A simple html and php example</title>
</head>

<body>
Here is a <?php echo ‘simple text’; ?>
</body>

</html>

After running the above snippet in your web server you will have the below html code when viewing its source in your web browser.

<html>
<head>
<title>A simple html and php example</title>
</head>

<body>
Here is a simple text
</body>

</html>

Quite simple? This is the stepping stone. Get the feel of it.

Try to think!!! What will it be like having hundreds of tit bits of php codes in your html. Urhh? Sounds messy? In fact, it becomes real messy. To counter this, you cal use templating engine. May be Smarty? This is the most recommended nowadays. I will talk about it in a later post. 🙂

Data is something unmissable for most of our websites. We all want a data backbone to play with. MySql? PostgreSql? Oracle? PHP can interface with almost any database server you can think of, urhh?? it can do so too with a simple access database (not a server). Connectors make this possible for us. We don’t need to know the underlying details.

I would recommend you to use MySql as your back-end. Open-source, free and strong going. And, it has made a reputation on the market.

PHP is a loosely typed language, that is it we do not need to strictly declare a variable in our script. We can do so as we go. Sounds good? Yes, but it is disadvantageous. (I will cover it in another post). We can cast from one data type to another. It just happens smoothly and it makes you mad while debugging at times.

PHP does not comes with a predefined security toolkit that you can just use. But, it comes with functions that you can use to build the weapon to fight evilness. 😛

We are given even more flexibility, we  can break down our code into its very own sub modules and include them together to make the whole “thing” or even put it anywhere we want it to.

I guess I have been able to try to build up a new thinking stream. Where you should maybe be heading. We will next be talking about syntax in my post.

In short PHP is a hot enough scripting language to mess with. It is your choice to love or hate it. Keep the reason(s) to yourself.