Posts tagged ‘PHP’

First PHP Program

Now its time to code and run your first PHP program. We have learned how to install XAMPP on your environment in the previous article.

So we have successfully installed xampp and now it’s time for PHP. 

i. Open notepad and copy paste the following PHP code into it or just use the attached file and copy it in htdocs folder inside xampp (eg:c:\\xampp\htdocs\).


<?php

 echo "<center><b>Kudos !!! You have successfully run your first PHP scrip on Windows</b></center>";
 echo "<br/><center><b>Welcome to <h2>PHP</h2> the language of web</b></center>";
 echo "<br/><center>For any PHP queries Contact :<a href='http://www.experts-exchange.com/M_5168010.html'>haijerome</a></center> ";

?>

ii Save the file as “haiphp.php” into htdocs folder of xampp server (eg: c:\\xampp\htdocs\) and select save as type “All Files”.

359289

If you don’t save your file type as ‘all files’ then you won’t get your PHP script running. Just because of this small issue, I have got a number of emails in my inbox and believe it or not, it forced me to write this article.  And I have to thank this issue, because i have got  a quite number of clients who turned into my friends later, all because of this little issue. So save you file type as ‘All Files’

And my kind suggestion is to use Notepad++ or if you want to be very professional then download Net Beans or buy Dream Weaver.

iii. Now type the url “http://localhost/haiphp.php” and see the PHP script running like a cake on your localhost web browser.

If you have followed the step ii of step 2 then type the URL like this http://localhost:81/haiphp.php assumed that your port number is 81.  If not, give the port number that you have saved as listen port number in the httpd.conf file.

359291

If you get any page not found or object not found or 404 error, then try with this http://localhost/xampp and conform whether you’re getting the xampp home page.  If it displays the XAMPP home page then verify that you have saved your PHP file inside htdocs folder and the file name as haiphp.php and file type as ‘all files’.

If you don’t even get the xampp home page, then make sure Apache is running.  Follow the article how to install xampp to get xampp or apache running on your  localhost to resolve object not found or object not found error no : 404.

August 2, 2010 at 6:47 PM Leave a comment

Installing Xampp

Download XAMPP,  an opensource package that holds Apache, PHP, MySQL, PERL (very old but powerful) which makes our work easier. Read more here (I mean the installation and configuration of PHP, Apache and MySQL on windows).  Download XAMPP self extracting RAR archive .EXE file which in turn is an easy way rather than a zipped archive. Install it on your top level folder / directory of any drive Eg : C:\xampp or D:\xampp. The instructions on the XAMPP web page are very clear with good screenshots.

A few words about XAMPP ingredients,

Apache – A powerful and popular Web server to run server side scripts like PHP, ASP, JSP, CFML etc. Read More

PHP – A simple, flexible, powerful and easy to learn and get help server side scripting language with huge community support. Read More

MySQL – An open source RDBMS (database management system) with great set of features and very compatible with PHP. Read More

PERL –  A 22 year-old powerful scripting language — perhaps a pioneer of PHP or server side scripting.   A person with the basics of ‘C’ and ‘UNIX’ finds it easier to work with.Read More

Now just open your folder where you have installed XAMPP and run the xampp control panel by running xampp-control.exe inside your xampp folder.

If you find the running… label highlighted in green color next to Apache and MySql then it is time to script your first PHP program, and our environment is ready.  If not, just click the check boxes near to Apache and MySQL to install them as Windows services and click start button.  (Wait for a while, don’t lose your temper — don’t click the start button again and again which you more likely to do as a beginner.)

At this point, some  get struck — they find Apache / xampp not running on localhost even after this.  Most of the times it is because the IIS (Microsoft’s web server) runs by default and occupied the HTTP port  : 80, which Apache demands by default. There are two ways to resolve this.

The easy way:
Type services.msc in the run window.  In other words Windows Key + R and type services.msc and click OK.  Find the IIS admin in the list of services shown in the window below.  If you find its status ‘started’ and startup type ‘automatic’ then right click on IIS admin and select Properties option in the pop up screen and stop the IIS service and change its startup type to disabled from the drop down list.  And click OK.



Now find Apache in the same list of services right click on it start the service and change its property as default start up type as ‘automatic’. Now click xampp-control.exe inside your xampp folder and start the MySql service.  That’s all.

OR…. the other way
The next way is to open ‘httpd.conf’ in the following location YOURDRIVE:\xampp\apache\conf. It is ia simple text file.   Change ‘Listen 80’ to Listen 81 or Listen 8085 or the port number you wish (but don’t use the reserved port numbers).


And restart your Apache and MySQL.

Note:
You can follow either of these two options as per your wish.  I don’t recommend or insist that you choose only one of them rather than the other one.

July 19, 2010 at 5:05 PM 2 comments

An Introduction to PHP

PHP commonly known as  Hypertext PreProcessor. And some of them expand it in other way Personal home Page. PHP is a the most popular open source scripting. Even some developers call it as The Language of web. It is the easiest server-side script to learn and to work with. To know more about the origin of PHP and who created it and who are all contributed to it, click here

What is a server-side scripting ?

A program resides in the server to respond the web client (browser) with a dynamic web content. Here’s a real time example, the Gmail’s sign in  form. In the login form you give your credentials (username and password) and click the submit button.  If you are valid user it will get you to your inbox otherwise ask you to enter your valid credentials. Well How Gmail validate your credentials. Yeah here server side scripting comes into the picture.  There is a piece of computer s/w program which resides in google mail server to validate your credentials and return you with a dynamic web content. And that s/w program is called as server side script or a server side program.

Why PHP ?

Even though there are many server side languages available like ASP, JSP, CFML, RoR, Python , PHP gains much more popularity than any of these. Its all because of its simplicity to learn and code. And also there are huge number of communities and forums are available on the web for PHP. Most of its syntaxes are borrowed from perl and C. Thats why its very robust and most people prefer it. Ok whats the orgin of php and who created it? Click here for the history of php.

Advantages of PHP

The following are the advantages of PHP over other languages.

  1. PHP is open source and license free. So it is cost-effectiveto develop a project using PHP.
  2. PHP is light weight. It doesn’t require much memory or system configuration to run.
  3. PHP runs on nearly every modern platform (operating system) in existence. So it is platform independent.
  4. PHP runs on both IIS and apache, the two most widely used web browsers.
  5. PHP has a huge community support and more number of learning resources available on the web.
  6. PHP has a big library of classes for all the common things needed for a web applicaiton like paging, csv export, reporting etc.
  7. PHP is faster than ASP.net and JSP in both processing and rendering web pages.
  8. PHP is easier to integrate with HTML

Besides these there are many advantages of PHP over other languages. If you want to know, Click here

December 31, 2009 at 7:22 PM 1 comment


Most Searched Keywords

magento PHP

Categories

Recent Posts

Blog Stats

  • 91,958 hits