Exercise PHP - 1

7/9/12


Welcome back! We have learned about PHP and MySql things. Now we will try some code in PHP and run it in your browser.

First you need some editor  for your code. There are some editor that can be used. For me, i’d like to use Adobe Dreamweaver as editor, you can buy it or searchin google for free product of it. 
But if you want free edition editor, you can download Notepad++. It’s simple application but have many functions. Not only PHP code, notepad++ can handle many programming language, such as Java, C++,Sql, css, html, and many others.

So now, i assume you have your own editor now, Let’s start.
1.       First of all, run your xampp ontrol panel and start apache and mysql service.
2.      Second, go into your explorer, go into : C:\xampp\htdocs

 Then create new folder, for example : Exercise

 Third, Go into your editor, we now want to display some addition function, let’s try this code below
Code for display Variable
Code for display Variable

Then, save it to the Exercise folder, with name index.php

4.      Fourth,  Go into your browser : then type : localhost/Exercise/index.php
5.       The browser should display like this
Result
Result


Look at step 4, it’s the link to open your work. Exercise is the folder, and index.php is the name file. 

Later, in complex website, which use many file and folder, it’s important to maintain your folder, so you won’t confuse where you place the file you want to display.


Let’s try another code. It’s all about operator, check this out.
Operator in PHP
Operator in PHP


The result is like this.
Result
Result
Okay, now you have try to implement the code and excecute it in your browser. Later in next post, i will give other exercise, that is more complex. So stay tune and keep practicing!

No comments:

 

Tags