Jump to content
xisto Community
Xenon

How do you test your php code

Recommended Posts

Usually I only write my code in my local box and upload to the remote box to test using some kind of pscp batch script. My local machine is Windows box and the remote server is Linux so the configuration is different. I prefer this way because I have too many apps installed in my local box and it's getting slower and slower. I will have to upgrade my box soon...

Share this post


Link to post
Share on other sites

Always locally, used to have Apache + mySQL + PHP all installed and configured seperately. But when I had to format my pc I found XAMPP much easier and less time consuming to configure.It's just so simple to hit CTRL+S (to save the file) then just hit F5 in the browser and see the outcome of the new edited file without having to upload it.

Share this post


Link to post
Share on other sites

I am using the WAMP server, one of the best servers to run php.No need to install Apache, MySQL and PHP separately.I am testing all my php scripts locally on my WAMP server. Congfigurationand running our servers in WAMP is very easy, I think. And I am usingPHPDesigner IDE for my PHP development. This is also nice software. After testing them all successfully on my local server, i upload themto remote server.

Share this post


Link to post
Share on other sites

I upload all my files to the server and test them. That way, since they're exactly where they'll be when I'm ready for production, I can see exactly how they'll render. The space I use at my school, unfortunately, has disabled php error messages, so every time something goes wrong, all I get is a large blank page. In a way, this is good since I've stopped coding entire projects without running a single test; now I test every little chunk of code as I write it in order to avoid sloshing through a thousand lines, trying to find a missed semicolon or open ".

Share this post


Link to post
Share on other sites

if you want to test PHP code for this i give all step which i thinks help you to solve your problem.
First step :
Download WAMP5 :
from any source you can search it on any search engine.
second step:
install it on your PC.
and fully configure it step by step process. on installation time.
or you may left on defalt setting.
run WAMP you see icon on tray WAMP icon see all services running or not if all services are running.
check all means Apache, mySql, PHP.

make a php file
for example:

A PHP file normally contains HTML tags, just like an HTML file, and some PHP scripting code.

Below, we have an example of a simple PHP script which sends the text "Hello World" to the browser:
test.php

<html><body><?phpecho "Hello World";?></body></html>

Each code line in PHP must end with a semicolon. The semicolon is a separator and is used to distinguish one set of instructions from another.

There are two basic statements to output text with PHP: echo and print. In the example above we have used the echo statement to output the text "Hello World".


if you see hello world then your test is successfull or if try it next time. when you got full knowlege.


We know that php is a server side scripting language. So we will need a server with the php parser to parse/test our code.How are you doing that. Do you upload it to a server for testing or did you instal php and the server (apache) on your computer (localhost)


Share this post


Link to post
Share on other sites

I belive you can use somthing as simple as Notepad. If you don't already know how to save PHP Files in Notepad:

Insert your PHP coding into a Notepad Document

'File' 'Save As'

Save the File as 'whatever.php'

Change the 'Save as Type:' to 'All Files'

Then Open your intenet Browser

Click 'File' then 'Open...'

Locate your File saved as 'whatever.php' and Open it

Then theres your coding.

That would probably be an easy way to test your PHP coding without downloading any programs :)

Share this post


Link to post
Share on other sites

I belive you can use somthing as simple as Notepad. If you don't already know how to save PHP Files in Notepad:

Insert your PHP coding into a Notepad Document

'File' 'Save As'

Save the File as 'whatever.php'

Change the 'Save as Type:' to 'All Files'

Then Open your intenet Browser

Click 'File' then 'Open...'

Locate your File saved as 'whatever.php' and Open it

Then theres your coding.

That would probably be an easy way to test your PHP coding without downloading any programs :)


No No Evloke. PHP doesn't work in the same way as html file. These two are different. You cannot run the php code by simply opening it through Internet Explorer. You need to run it through the web server(like apache). For that you need to point your php file to the web server.

 

If you are running it in your local computer you can do this by entering the following address in your browser.

LOCALHOST/filename.php

 

Before that you must have a web server running. And the file should be placed in the respective folder of the server (for example www folder in the WAMP server) . Hope you got it now. If not ask me.

Share this post


Link to post
Share on other sites

It is reccomened to use a localhost server. Try download xampp its really good it comes with a apache server, mysql, phpmyadmin, a ftp client and a mail server!If you do download it to upload your files you simply go to your harddrive .Click on the xampp folder then click on Htdocs. Then either make a new folder and copy and paste your files into there (reccomended) or just copy and paste them into there.Next open up a new internet page and type in the address bar localhost/( your file or folder name goes here) For example if i called a file name test.php I would type localhost/test.phpHope this helps.Surbjit:)

Share this post


Link to post
Share on other sites

I am testing them twice so I will have results that I really want to.. first test will be locally then the second with my host..you can use xampp and the like and just install them in your computer.. there are many kinds of programs like xampp, just search the net and you will find one..

Share this post


Link to post
Share on other sites

Well, i prefer to save it on my computer, then save it to my FTP. But another good way, is to edit it using Cpanels code editor. Then you just click save, and refresh the browser page to see the effect.However, this does have its disadvantages, like, you can only have on one instance of code editor running, and if you make a mistake and save it, you have no backup (obviously you can avoid this by just backing up every now and then)There are also some web editors which have built in PHP interpreters.

Share this post


Link to post
Share on other sites

We know that php is a server side scripting language. So we will need a server with the php parser to parse/test our code.How are you doing that. Do you upload it to a server for testing or did you instal php and the server (apache) on your computer (localhost)


Dear friend I generally after creating a php page test it with my web hosting service provider I don't know but I think its a difficult one to make your own server to just test your php pages. 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.