Alexancho Posted December 29, 2009 Share Posted December 29, 2009 I have learned HTML, CSS, JavaScript and now i installed a WampServer and want to learn PHP.The question is how can i execute PHP program to see the result. For example, the script is <?php$txt="Hello World";echo $txt;?> ( http://www.w3schools.com/php/php_string.asp )What should i do to see this "Hello World" written? Link to comment Share on other sites More sharing options...
Redroest Posted December 29, 2009 Share Posted December 29, 2009 Instal a appache server and run php files from their root folder. Appache is not standard included into a windows platform but it is needed to run php.I recommand wamp 5. Just google on it. Insert your php files/website in the www map and browse to http://localhost/yourfile.php to view the files Link to comment Share on other sites More sharing options...
justsomeguy Posted December 29, 2009 Share Posted December 29, 2009 Apache isn't needed to run PHP, but he said he already downloaded Wamp. If so, you need to figure out where your web root is and save your file there. Check the documentation for wamp to see where it puts the web root, it may be somewhere inside Program Files. Save your PHP file into the web root, and then you can access it over HTTP like Redroest showed. Link to comment Share on other sites More sharing options...
Alexancho Posted December 30, 2009 Author Share Posted December 30, 2009 Thank you very much.It works. I created a folder inside root folder for my php files and run them on localhost.But for that i need to write the address in address bar of a browser or create a link.Is there an easier ways to run PHP files like we have for html files?And could you recommend me a PHP Editor? Link to comment Share on other sites More sharing options...
Err Posted December 30, 2009 Share Posted December 30, 2009 Once you get WAMP running, you can left-click the icon and click on localhost as quick link. You can find many text-editors here. Link to comment Share on other sites More sharing options...
Alexancho Posted December 30, 2009 Author Share Posted December 30, 2009 Once you get WAMP running, you can left-click the icon and click on localhost as quick link. You can find many text-editors here.Yes. Of course, you are right, but this way you can only open http://localhost/ in your browser.For example, if i have 20 html files in some folder i can open them one by one by double click or by simple drag and drop. If i have 20 php files in folder my_test i should write in an address bar something like this:http://localhost/my_test/test1.php and change it manually 19 times or to create an html file with 20 links.The question is whether there is a better method? Link to comment Share on other sites More sharing options...
Err Posted December 30, 2009 Share Posted December 30, 2009 Are you talking about browsing to files while in your localhost?You can get a directory listing of all the files you have inside a certain folder if you do not have an index page in that folder. WAMP by default is set to show directory listings if no index page is found. Here's what I mean: Link to comment Share on other sites More sharing options...
Redroest Posted December 31, 2009 Share Posted December 31, 2009 Well thats the downside of making serversided systems I guess. unlike html, php is a programming language. This means that php is able to output the html pages. html is a markup-language for your browser and javascript is a client-side language it means that the data is already send to YOU (the client) and is ready to display on your browser. php can't display itself, it can only output things to display.Please correct me if I am wrong about this, but I am working with this philosophy since I program php. Link to comment Share on other sites More sharing options...
Err Posted December 31, 2009 Share Posted December 31, 2009 Redroest, that's true, but your missing some important details. You can view regular html files by directly clicking on them without the need for it to go through a server because HTML, CSS, and JavaScript are all processed by the client-side (AKA your browser). PHP is server-side, your browser doesn't know how to process server-side code, so if you try to view a PHP file with PHP code in it without going through a server, the browser will try parse the PHP code as html or text making the PHP code spill all over your page. PHP will simply output the end result of whatever your PHP code was doing.You can just use WAMP as your development server for everything now, including regular HTML files. You can get quick access to these files through the previous method I mentioned. Link to comment Share on other sites More sharing options...
Alexancho Posted December 31, 2009 Author Share Posted December 31, 2009 Thank you, RahXephon. I deleted index.php and now i can see directory listings.Actually it is just what i wanted. Thank you very much. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.