查看: 1720|回复: 0

[教程] 【一网打尽】Raspberry Pi Course Week 6 – Day 4 (Installing PHP)

[复制链接]
  • TA的每日心情
    开心
    2016-8-4 10:56
  • 签到天数: 242 天

    连续签到: 1 天

    [LV.8]以坛为家I

    发表于 2015-3-28 13:49:25 | 显示全部楼层 |阅读模式
    分享到:

    Apache is installed and is now delivery pages to clients or in other words a web browser.  HTML pages are good but lack any major interactivity and are not dynamic enough for today’s web sites. PHP offers a solution to dynamic  web pages by allowing pages to make decisions based on input or data from an external source such as a database or another web site.

    The first step will be to install PHP.  This is done from the command line by entering the following.

    $ sudo apt-get install php5

    We will also install the php-mysql package that will allow php web pages to interact with the MySQL database.

    $ sudo apt-get install php5-mysql

    $ cd /var/www

    $ sudo nano test.php

    Enter the following php code into the test.php document.

    <html>
    <head>
    <title>PHP Test</title>
    </head>
    <body>
                    <?php phpinfo(); ?>
    </body>
    </html>

    You can see that the structure of a php follows the same rules as the HTML file did but the big difference is the tag the starts with <?.

    * When PHP parses a file, it looks for opening and closing tags, which are which tell PHP to start and stop interpreting the code between them. Parsing in this manner allows PHP to be embedded in all sorts of different documents, as everything outside of a pair of opening and closing tags is ignored by the PHP parser.

    PHP also allows for short open tags (which are discouraged because they are only available if enabled with short_open_tag php.ini configuration file directive, or if PHP was configured with the –enable-short-tags option. *

    This indicates that you are about to create some php code so rather than outputting the words php phpinfo(), it will instead call a function called phpinfo().  This function will display information relating to PHP and the apache server.

    Later lessons will explore PHP in more detail.

    * Contribution by Steve.  Thank you for expanding on this.


    回复

    使用道具 举报

    您需要登录后才可以回帖 注册/登录

    本版积分规则

    关闭

    站长推荐上一条 /4 下一条



    手机版|小黑屋|与非网

    GMT+8, 2024-11-19 13:32 , Processed in 0.103016 second(s), 15 queries , MemCache On.

    ICP经营许可证 苏B2-20140176  苏ICP备14012660号-2   苏州灵动帧格网络科技有限公司 版权所有.

    苏公网安备 32059002001037号

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.