How to write PHP script for website?

I am crazy about writing script but no idea how to write it. Is there any software? please tell me what skills are required to become a complete web developer because I am going for certification courses please also suggest me which course is best for me, I hope this forums have many professionals who give me their professional advice.

Before jumping into getting yourself a web server and messing about with hosting configurations, install a piece of software called ‘xampp’. Google ‘xampp for windows’, for installation directions search ‘xampp installation’ on YouTube.

Once you have got xampp installed you can start working through some example and tutorials without the the distraction of virtual boxes and other stuff like that. Good luck

Thanks to both of you, I am going to install xamps but which type of course you suggest me to do first? javascript or PHP?

PHP is a scripting language which runs on the server. You only need a text editor like Windows Notepad to create texts. You will likely need to install a Web Server on your home system on which to develop and test your scripts.

Then buy yourself a decent beginners book, or find some tutorials online.

I installed apache 2.5.7 on windows 7 but my test files are not running why? I just started with basic example of php after saving in .php extension in document root directory which is “www” its not working on my browser. I typed on address bar http://localhost/filename.php but its nothing… Kindly tell me what is the problem?

You need to run a local server on your machine in order to check that your scripts function correctly (unless you are so sure about your programming skills that you believe such a verification won’t be necessary).

I recommend that you use WAMP, which is a package comprising an Apache server along with the last version of PHP and MySQL; it can be run locally on your computer.

Its a very lengthy process to write code for a website. You need to go for a PHP training first then you can write code in PHP for a website.

<snip/>

@trish456 Thanks for WAMP, I installed successfully and its working great.

You need to go for a PHP training first

Hmm you are right, without training I can’t become a php developer…

You can teach yourself. Books and online tutorials are popular, as I said, but you can also register for online video courses too.

It’s usually the advice like this one that beginner will follow, try it, and quickly loose all their enthusiasm, rightfully so.
DO NOT WRITE PHP in WINDOWS Notepad! Ever! Even the best php programmer will make mistakes when using notepad.
You can’t make it far beyond a simple “Hello world” script in Notepad, even then you can make a mistake
Instead first tool you need, before you write your first line of php is a good editor, called IDE. There are many good free ones out there. Look into NetBeans for php or PHP Eclipse.

The advantage of an IDE is it will do all the hand holding for you, correcting your mistakes while you write your program.

Thanks ultra1 its really good for beginners. I also downloaded many ebooks and i hope one day i will cover all these tutorials contain in Ebook.

I think it is a case of horses for courses, so I will put an alternative view to that posed by Ultra1

For a complete newcomer using an IDE like Netbeans (and god forbid, Eclipse) immediately adds layer of abstraction between the coder and the software stack. An IDE is fine if you already use it, or you have an inkling of what is going on under the hood.

I’ll be honest, I frown on using an magic installer like WAMPP for the same reason. As a programmer you need to understand how all this stuff is wired up, the importance and relevance of settings in your php ini file and so on, how where and why key files are stored on your HDD.

If you cannot install each component and wire them up together, then you probably should not be coding in any case. I don’t say this stuff is easy or that you wont hit numerous problems, but boy will you learn a lot!

I am not saying IDEs or Installers are bad, they have their place when you have got up to speed – or as I say, you have fully assimilated how the stack plugs together. Then there are real benefits to be had.

They also have a place for those who just want to see instant results, which is the right thing for some people, I acknowledge that it builds their confidence up.

But it is not right for everyone, it was not right for me.

Its a bit like learning to drive a manual gear box car compared to driving an automatic transmission car.

I use magic installers myself now when I want specific setup, and I use an IDE when I know I am going to accessing big code libraries and I want all the bells and whistles working on my behalf. The rest of the time I use a text editor, I don’t need anything else. I make mistakes just like everyone does - but I have learned how to identify and fix them in my brain, and with the help of friends here.

I first started writing code (BASIC) from the command line, no text editor let alone an IDE. My first website was on AOL Hometown using HotDog Express. Worlds apart from a coding perspective.

When I wanted to add more to the website I started learning HTML from studying view-source (picked up a lot of bad practice) and quickly learned to use Notepad not Word.

I’ve used Notepad to write HTML, CSS, Javascript, Java, PHP, Perl, and others over the years since without much trouble.

Two problems I did run into were when a file became too large for Notepad’s memory, and the lack of line numbering. Notepad++ has since become my text editor of choice.

I’m not interested in RAD so things like code completion don’t really interest me much as I don’t need them. But if I was cranking out websites for a living it would be different. As for mistakes, simple typos are no problem, logic errors a bit trickier, and code flow and bottle-necks a bit more. AFAIK no IDE can help much with the latter.

To me, I think having to learn both the code’s language and an IDE at the same time would have been a bit overwhelming and might have caused me to give up.

I see no problem with using Notepad during the learning stage and saving the IDE until later.

One extra nice thing about IDE is code formatting, indentation of block of code, etc. Just makes the code much more readable, which is important. When writing more than just a few lines of code it’s easy to forget to close a bracket here and there, especially with multiple levels of nested blocks, forget semicolon here and there… The IDEs are very good at spoting these types of errors and that makes life a lot easier, so you don’t wait until you actually run the code to see an error. Code completion is also very helpful, so you don’t accidentally misspell the function name.

Using IDE is for experts and professionals in my opinion not for the beginners as already mentioned. Specially the code completion is not good for the beginners because they have to know what function he is going to type and type himself with the knowledge of its arguments and off course for right purpose.

Forgetting to type semicolons and brackets is the main problem. While learning one has to remember to open and close brackets so that better practice remains for the later. IDEs are not available everywhere sometimes you may alter the code in notepad like editors or sometimes you may need to edit the code in a text area in the web page itself, in that case the practice of IDE’s use will really be felt bad yourself. So first practice I would also recommend to use normal editors like notepad or at least use notepad++ which is easy enough for syntax highlighting.

And regarding automatic installers for AMP is also not good for anyone (not even for experts). I have an experience like I used to use WAMP in my laptop for development purpose for sometime and I was asked to enable a GD library in PHP and mod_rewrite module in Apache and the PC was not mine and didn’t have WAMP. Somone had installed individual packages already. I had to go out and search in Google to know how enable them. At least if I had not used WAMP and then I would have known such small things. Though I use and IDE ‘NetBeans’ these days but I never use WAMP/XAMPP anymore and I came to know a lot about configurations/settings of PHP and Apache and even MySQL.

Enabling extra modules in php is beyond beginner level anyway. Second, if you need to enable the extra module in WAMP envoroment, then you really should know how it’s done in WAMP, which will be different on Linux. This is not a topic for beginners anyway. WAMP is very good for local development envoroment, so you have a working Apache server with php on your local PC and can execute your scripts right away. It’s, I would not use it for production sites.