wrong print out to the browser

I am new to php, can some one please help me with this issue; I wrote a simple script

<?php print "hello web"; ?>

ideally the output to the browser should only be:
hello web

but the actual output is:
hello web"; ?>

I am guessing the print statement prints the string of characters all the way to the end of the script, so if had more statements after the print statement, they would also be printed out to the browser. I have also tried removing the tags; but when I do that, there is no output to the browser. Any help is appreciated, Thanks.

Ok, please don’t be offended by my following questions:

Do you have a PHP installed on the server you trying to do you scripting on? If so are you sure that php is running?
To know for sure you should create a phpinfo page. Just simple create a new document. Then add this: <?php phpinfo(); ?> Save the document and run it on the server that should have php installed.

What do you see? Do you see a bunch of information about php. Like what version is running and all the modules running?

If you do see all this and are sure php is running then try this simple script.

<?php echo "Hello Web"; ?>

Let us know your results.

I followed the guidelines to install mysql,apache2, and php from http://switch.richard5.net/. and now php should be installed, this time when i load the script

<?php phpinfo(); ?>

the script itself is output to the browser. What files do i need to modify to enable php?

Ok, this is a good thing. At least now we know where the problem lies. I have been working with PHP, Apache, MySQL for a long time and I can tell you when I first started out, I tried turning my home machine into a development machine. So I did as you did and download the packages and tried to configure and install everything. Spent weeks trying to get it and never could.

Here is what I finally did which may or may not be an option for you:
Uninstall the packages you installed. PHP/Apache/MySQL.

I am guessing you are on a Mac OS X machine by the link you provided. Here is what I did only I am on a windows machine, but I did research and I did find similar packages for Mac.

I use WAMP. Windows Apache, MySQL, and PHP. I looked and there is MAMP, Mac Apache, MySQL, and PHP. These packages, at least on the windows box install everything and configure most things for you. These packages install and configure very easily. Probably be up and running in less than 10 to 15 minutes.

Here is a link to the site I found:
http://www.mamp.info/en/home/

I only did about 2 minutes worth of research so you may want to check around see what you can find.

Hope that helps.

Sponsor our Newsletter | Privacy Policy | Terms of Service