0

I am new to HTML and PHP.

All I want to do is that I made a HTML file and a PHP file and now I want to test it on my local server i.e. my own computer. My HTML file includes the following code:

<html>
   <head>
      <link rel="stylesheet" href="stylesheet.css" />
      <title>Codecademy Languages</title>
   </head>
   <body>
     <h1>Languages you can learn:</h1>
     <div class="wrapper">
       <ul>
       <?php include 'Test001.php'; ?>
       </ul>
     </div>
   </body>
</html>

and my PHP file named as Test001.php includes the following:

  <?php
      $langs = array("JavaScript",
      "HTML/CSS", "PHP",
      "Python", "Ruby");

      foreach ($langs as $lang) {
          echo "<li>$lang</li>";
      }

      unset($lang);
    ?>

How can I test the whole thing in my web browser? I am using Linux Ubuntu

Many Thanks

Jatin
  • 3,005
  • 6
  • 27
  • 42

2 Answers2

1

if you installed apache then go to /var/www directory. create a folder there . then paste your code files there . then open a terminel .. and change the permission of folder. for your local project i suggest to give full permission as you are starter .. command is

chmod 777 -R /var/www/your_folder_name  // use sudo in start if user not root

then open up a browser then go for link ...

localhost/your_folder_name/Test001.php

your must see output for your php file

Fisherman
  • 5,669
  • 1
  • 26
  • 34
  • This one worked perfectly. Thanks. Only another question is that if I have a ".css" file as will so shall i put it in the same folder and run PHP file or there is some other way to test the css? – user3461530 Mar 25 '14 at 20:59
  • no matter where you put it should be in your server i mean public folder and you properly link it to your files – Fisherman Mar 25 '14 at 21:19
0

First you have to install some software, there is a software named "LAMP".

Here you can see the official ubuntu tutorial -> Tutorial click here

What is LAMP? LAMP is a box that contain some little software :

 - Server (apache2) : Entity that discuss with your browser
 - PHP5             : Install the langage
 - MySql            : Install the langage Mysql used to interact with BDD

Second you have to go into your brower and type "localhost" into http:// input.

Third if you want to access to your html file, put it into /var/www directory (in your computer) and access it using http:// input.

Example :

 - Name of the file is '*toto.html*'
 - Type '*localhost/toto.html*' into *http://* input

If you have any questions about that, you are welcome buddy :)

Orelsanpls
  • 20,654
  • 4
  • 36
  • 61