Home > Backend Development > PHP Tutorial > PHP background data processing and data interaction with the web side

PHP background data processing and data interaction with the web side

WBOY
Release: 2016-07-29 09:00:42
Original
1175 people have browsed it

一 What is PHP?
PHP (foreign name: PHP: Hypertext Preprocessor, Chinese name: "Hypertext Preprocessor") is a general open source scripting language. The syntax absorbs the characteristics of C language, Java and Perl, which is easy to learn and widely used. It is mainly suitable for the field of Web development. PHP's unique syntax mixes C, Java, Perl, and PHP's own syntax. It can execute dynamic web pages faster than CGI or Perl. The execution efficiency is much higher than CGI that completely generates HTML tags; PHP can also execute compiled code, and compilation can achieve encryption and optimization of code running, making the code run faster.

2 Which common languages ​​can write background data?
1 JAVA, LUA (more commonly used in embedded web terminals), .net, asp, php, the latter is more commonly used in the website backend.
Third, what is Apache?
Apache HTTP Server (Apache for short) is an open source web server of the Apache Software Foundation. It can run on most computer operating systems. It is widely used due to its multi-platform and security and is one of the most popular web server-side software. one. It is fast, reliable and extensible through a simple API to compile interpreters such as Perl/Python into the server.
Main code: The specific environment configuration will not be discussed here

<code><span><span><?php</span><span>$resut</span> = mysql_connect(<span>"127.0.0.1"</span>,<span>"root"</span>,<span>""</span>);
    <span>if</span>(<span>$resut</span>){
        <span>//echo("连接成功"."</br>");</span>
    }<span>else</span>{
        <span>//echo("连接失败"."</br>");</span>
    }
    <span>//选择要操作的数据库,相当于之前的打开数据库。</span><span>$value</span> = <span>$_GET</span>[<span>"username"</span>];
    <span>$value1</span> = <span>$_GET</span>[<span>"password"</span>];

    mysql_select_db(<span>"lyg"</span>);
    <span>//准备sql语句</span><span>$sql</span> = sprintf(<span>"select username from account where username='%s'"</span>,<span>$value</span>);
    <span>//执行sql语句</span><span>//执行sql语句,</span><span>$result</span> = mysql_query(<span>$sql</span>);
    <span>//获取到查到的结果 只取一行,可以通过while循环获取所有结果</span><span>$dic</span> = mysql_fetch_array(<span>$result</span>);
    <span>//判断查找结果中username是否为空</span><span>if</span>(<span>empty</span>(<span>$dic</span>[<span>"username"</span>])){
        <span>$sqls</span> = sprintf(<span>"insert into account (username,password)values('%s','%s')"</span>,<span>$value</span>,<span>$value1</span>);
        <span>$result</span> = mysql_query(<span>$sqls</span>);
        <span>if</span>(<span>$result</span>){
            <span>//echo("插入成功");</span><span>$resultDic</span> = <span>array</span>(<span>"resultMess"</span>=><span>"注册成功"</span>,<span>"resultCode"</span>=><span>"100"</span>,<span>"userID"</span>=><span>"201632"</span>);
            <span>echo</span>(json_encode(<span>$resultDic</span>));
        }
    }<span>else</span>{
        <span>$resultDic</span> = <span>array</span>(<span>"resultMess"</span>=><span>"注册已存在"</span>,<span>"resultCode"</span>=><span>"200"</span>,<span>"userID"</span>=><span>"201632"</span>);
            <span>echo</span>(json_encode(<span>$resultDic</span>));
    }


<span>/*
class MyClass
{
    protected function myFunc() {
        echo "MyClass::myFunc()\n";
    }
}
class OtherClass extends MyClass
{
    // 覆盖了父类的定义
    public function myFunc()
    {
        // 但还是可以调用父类中被覆盖的方法
        parent::myFunc();
        echo "OtherClass::myFunc()\n";
    }
}
$class = new OtherClass();
$class->myFunc();
*/</span><span>?></span></span></code>
Copy after login
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces PHP background data processing and data interaction with the web side, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template