↓ Archives ↓

Archive → December, 2011

How to Write Your Very First PHP Program

Advanced programmers know a secret. The secret that they know relates to how a PHP program is constructed.

Here is the secret:

“Complex programs are built up from simple programs. If you can learn how to create a simple program, you can learn how to build a complex program, no matter how complicated.”

A program can be constructed of only a few lines. They always start the same way. Start with the PHP start tag, followed by your programming code, and last by the PHP end tag.

Example 1:</p> <p>Line 1: <php line your program goes here></php>

The PHP program shown above has only 3 lines. Line 1 & 3 are the start and end tags, line 2 is your functional code. In this case however, line 2 is a comment and will not perform any specific action other than to remind you of something. Comments are not processed by the interpreter. Once a comment is encountered, it is basically ignored.

Example 2:</p> <p>Line 1: <php line this is one comment another the last></php>

The code in example 1 behaves exactly as the code in example 2. Even though example 2 has 2 more lines. If you noticed, the additional lines in example 2 are only comments. Once again they are ignored by the PHP interpreter (PHP Engine).

If there is one comment or multiple comments, the interpreter will act the same way. It will ignore any comments that it finds.

Example 3:</p> <p>Line 1: <php line below this is a real php programming command echo first program></php>

In example 3 you will see your first functioning PHP program. The ‘echo’ command was added to this program, located on line 3. An ‘echo’ statement is a built in PHP command that will output whatever follows it to the screen. Anytime you want to output something using PHP to the screen, web browser, or visual display. Use the simple ‘echo’ command.

As you can see, the words ‘My First Real Program’ follows the ‘echo’ command. It is very important to enclose the words that you want ‘echoed’ on the screen inside single or double quotes. This way the echo command knows from what character to start with, and

what character to end with, as it generates the output to the screen.

When the echo command is called, it takes the contents inside the quotes, and sends it out to the screen – minus the quotes. So the output would be:

My First Real Program

Example 4:</p> <p>Line 1: <php line the next is first echo command are second how to last in php></php>

The output to this program would be:

You are learning how to program in PHP.

When you start programming, there is no limit to how many comments and commands you can enter in your program. Go ahead, try it yourself. As you get better you won’t need so many comments to remind you of what you are doing in your program.

Complex programs are made up of simple programs. Learning how to mix simple commands together, along with PHP start and end tags makes a fully functioning PHP program. As you are learning, a good suggestion is to add as many comments as you need to help remember what you are doing. Comments are like taking notes that you can refer back to. As you get better at programming, you will naturally enter less comments. The PHP ‘echo’ command outputs characters to the screen. Enclose all characters after an ‘echo’ command with single or double quotes.

Congratulations, you just wrote your first PHP program.

Paul Markovich is a Lead Technical Trainer.

He has been designing and building custom web sites for entrepreneurs since 1997. He’ll help you get the answers to your burning open source programming questions!

Looking For More PHP Programming Tips?

Discover Proven Programming Strategies.

Learn to Program faster, while saving time, energy, and money!

http://centeroftech.com

Article Source:
http://EzineArticles.com/?expert=Paul_Markovich

Car Insurance Rates – Can You Lower Them?

Car insurance rates are prohibitive nowadays. Many families really struggle to pay the car insurance bill each month. And car insurance rates vary all the time. So if car insurance cost is an issue for you, what can you do about it?

The car insurance industry is a massive industry. It is also a highly competitive one, and car insurance rates vary over time as car insurance companies compete for business. Car insurance rates are often highly fluid.

It is entirely possible to lower the cost of your auto insurance rates by altering your behaviour, and you can do this by having a better understanding of how the rates are assessed.

Car insurance rates are based on an assessment of risk. Whilst insurance companies vary their rates to compete with other insurance companies, they also vary their rates based on their assessment of the risk posed by a particular driver driving a particular car. They do this because there is no point in buying business with low car insurance rates and then insuring high risk drivers at these rates. This is a recipe for losing money.

So, if you lower your risk, you lower your car insurance. How do you

lower your risk? Well there’s a number of ways that your own driving and car behaviour can affect your car insurance rates.

Have a look at the car you drive. Is it suitable for your current needs? If not then would it be worthwhile to consider a change?

Different cars attract different auto insurance rates. Sports cars, high powered cars and cars at greater risk of theft attract higher rates. How long have you had your car and would it be wise to think about another one that would be cheaper to insure and more useful to you?

Are you a safe driver? Do you stick to the speed limit? Are you at risk of other driving offences? Many people do not think about some of the consequences of speeding tickets and driving offences until after they have seen their subsequent car insurance bill.

Your risk profile is a direct result of your driving record. A clean driving record and you will be rewarded by cheaper rates. A poor driving record and you will be penalised, usually for quite a while.

Are you willing to attend driver training courses? Many car insurance companies offer specific discounts for drivers who have attended a course. Why? Lower risk.

Are you willing to drive less? Could you car pool or use public transport to get to work? Car insurance companies look at the amount of driving their clients do when assessing their car insurance rates. Why? Lower risk. Less miles driven equals less risk. And you’ll save on other car costs too.

So if auto insurance costs are an issue for you and your family there are things you can do. These are just a few of those things, there are many more. Car insurance rates are not set in stone.

For a website totally devoted to Car Insurance visit Peter’s Website Car Insurance Answers and find out about Car Insurance as well as Cheap Car Insurance and more, including Online Car Insurance Quotes, UK Car Insurance, Car Insurance Rates and Car Insurance Quotes.

Article Source:
http://EzineArticles.com/?expert=Peter_Crump