I need some explanations for how to execute the following PHP code. I am using Notepad++ & wamp server. All of files.php are to same directory.
Thanks ///////////////////////////////
index.php
//////////////////////////////
<?php
require("decide-lang.php");
?>
<html><title>Exercice </title>
<body>
<?php echo TXT_INDEX; ?>
<p><br>
News: <?php echo TXT_NEWS; ?> <br>
Conseil du jour: <?php echo TXT_CONSEIL_INDEX ; ?> </p>
<p> </p>
<p><a href="index.php?lang=en">Not french??</a></p>
</body>
</html>
//////////////////////////////
decide-lang.php
//////////////////////////////
<?php
if ($lang=='fr') { // si la langue est 'fr' (français) on inclut le fichier fr-lang.php
include('fr-lang.php');
}
else if ($lang=='en') { // si la langue est 'en' (anglais) on inclut le fichier en-lang.php
include('en-lang.php');
}
else { // si aucune langue n'est déclarée on inclut le fichier fr-lang.php par défaut
include('fr-lang.php');
}
?>
//////////////////////////////
en-lang.php
/////////////////////////////
<?php
define('TXT_INDEX', 'Welcome on YOu_Site.com!');
define('TXT_NEWS', 'The sun is shining !');
define('TXT_CONSEI开发者_StackOverflow中文版L_INDEX', 'Lets do some PHP !');
?>
//////////////////////////////
fr-lang.php
/////////////////////////////
<?php
define('TXT_INDEX', 'Bienvenue sur votre_site.com !');
define('TXT_NEWS', 'Il fait un soleil radieux !');
define('TXT_CONSEIL_INDEX', 'Faites du PHP !');
?>
- Put your .php files in htdocs folder of wamp.
- Run your wamp.
- Open a web browser.
- Go to http://localhost/yourFile.php
Note 1: If you have a file named index.php, you can goto http://localhost/ to see that
Note 2: You can make a folder in htdocs folder and name it as your project, so you may go to http://localhost/myProject/myfile.php
Run your php file in a web server: http://localhost/index.php
Run you php file on the command line: >php index.php
精彩评论