开发者

How to execute a php code [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

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>&nbsp;</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 !');  

?>


  1. Put your .php files in htdocs folder of wamp.
  2. Run your wamp.
  3. Open a web browser.
  4. 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


  1. Run your php file in a web server: http://localhost/index.php

  2. Run you php file on the command line: >php index.php

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜