PHP学习回忆

Jun 23, 2016 pm 02:33 PM

PHP学习回忆


 花?成两个月学??PHP?皮毛,算是写?个完整??出?
?住将呢两个月学到??记低,费事以后忘记?啦,做吓记念都好

----------------------------------------------------------------------------------------

PHP学习回忆 1
现在让我们开始吧~~

环境的搭建
先讲一下WAMP的搭建(WINDOWS+APACHE+MYSQL+PHP)
WINDOWS:WIN2K SERVER SP4
APACHE:2.0.59
PHP:5.2.1-dev
MYSQL:5.0

安装Apache
首先从http://httpd.apache.org/下载WINDOWS的MIS安装包,安装后打开IE,输入http://localhost,如果显示It Works,表示安装成功。

安装PHP
到http://www.php.net下载windows的ZIP包,随便解压到一目录,例如:c:\php,进入解压目录,找到php.ini-recommended,改名为php.ini,打开php.ini,找到doc_root = ,把路径改你要设置的WEB路径,例如doc_root = "c:\web",找到extension_dir = ,改为extension_dir = "c:\php\ext"。

以下设置为PHP加载相应模块
找到以下内容
extension=php_mbstring.dll
extension=php_gd2.dll
extension=php_imap.dll
extension=php_msql.dll
extension=php_mysql.dll
extension=php_xmlrpc.dll
extension=php_xsl.dll
extension=php_mysqli.dll
把前面的分号去掉。

以下设置为PHP设置SESSION和COOKIES
找到session.save_path = ,改为你要设置的session路径,例如session.save_path = "c:/temp",如果系统不需要设置session的话,这里可以不设置。
找到session.use_cookies = ,改为session.use_cookies = 1,同样,如果不需要使用cookies的话,这里可以不用设置。
找到session.name = ,改为session.name = PHPSESSID。
找到session.auto_start = ,改为session.auto_start = 0。

以下设置mbstring默认语言
找到mbstring.language = ,改为mbstring.language = Chinese simplified。
保存并退出。

在c:\php目录下找到php5ts.dll、libmysql.dll,copy到c:\winnt目录下

设置Apache
进入Apache安装目录下的conf目录,找到httpd.conf,用记事本打开,找到Listen,这个值是WEB服务的监听端口,默认是80,可以修改为你要设置的其他端口。
找到Dynamic Shared Object (DSO) Support,加入动态共享文件
在最后面加入LoadModule php5_module "C:/PHP/php5apache2.dll",如果是PHP4,则改为LoadModule php4_module "C:/PHP/php4apache2.dll"。
找到ServerName,改为服务器的计算机名,例如:ServerName HOSTNAME:80,如果已经入域,最好输入FQDN。
找到DocumentRoot,改为WEB的默认路径,例如:DocumentRoot "c:/web"。
同样,找到,改为
找到AddType application/x-gzip .gz .tgz,在下面加入以下内容
ScriptAlias /php/ "c:/php"
AddType application/x-httpd-php .php .php5
Action application/x-httpd-php "/php/php-cgi.exe"
PHPIniDir "C:/php"
保存并退出。


到这里完成Apache和php的设置,重启Apache服务,如果正常启动,在c:\web目录下新建一个用记事本,输入以下内容:

另存为phpinfo.php,打开http://localhost/phpinfo.php,如果正常的话,会显示服务器的PHP设置环境,则说明设置成功,并能找到已经加载的信息,例如gd2、msql、xmlrpc、xsl等。
如果Apache服务启动失败,或打开http://localhost/phpinfo.php只显示文件内容,则说明设置有问题,可以查看Apache的log文件进行排错。


好耐没更新了,继续

接住落?去http://www.mysql.com下载Mysql
一路安装,安装过?会要求设置管理员密码
安装好后,在CMD里登录,mysql -u root -p
然后输入root密码,输入以下内容,就
SET PASSWORD FOR
'some_user'@'some_host' = OLD_PASSWORD('newpwd');
之后就能正常登录Mysql了

如果忘记了 MySQL 的 root 密码,可以用以下方法重新设置:

    1. KILL掉系统里的MySQL进程;

    2. 用以下命令启动MySQL,以不检查权限的方式启动;

    mysqld_safe -skip-grant-tables &

    3. 然后用空密码方式使用root用户登录 MySQL;

    mysql -u root

    4. 修改root用户的密码;

    mysql> update mysql.user set password=PASSWORD('新密码') where User='root';mysql> flush privileges;mysql> quit

    5. 重新启动MySQL,就可以使用新密码登录了。

Mysql手册第二章有介绍

-----------------------------------------------------------------------------------

PHP学习回忆2
定义变量:
$i; //定义一个$i变量,可以是任意类型
$i = 123; //定义一个$i变量,int型,当然也可以是float等。。。
$i = "123";
$i = '123'; //同上,定义一个$i变量,string型

''和""有什么区别?忘记了,如果字串里只有字串,不包含其他的话,用''比较好,如果有其他东西的话,最好用""吧,例如包含变量、常量NULL等。。。
一个简单的例子:
$i = "今天是{$today}";
上面的例子是定义一个$i变量,内容是“今天是{$today}”,$today是另外一个变量,内容是今天的日期,例如是“2007年1月29日”
当输出变量$i时,内容是“今天是2007年1月29日”
那么,{}的作用是什么呢?当字符串中包含有变量时,可以用{}包含变量名,输出字符串时,当PHP遇到$xxx后,会在程序里寻找变量$xxx,找到变量$xxx的值后,再把相应的值输出,然后继续输出原字符串

PHP里面的输出
echo
echo可以输出变量值、字符串、数字
例如:
echo $i; //输出变量$i的值
echo "123";
echo '123'; //同上输出字串123,不带""或''
echo 123; //输出数字123
因为PHP是HTML嵌入式语言,所以echo也可以输出HTML代码
例如:
echo "

";
以上代码输出一个一行一列的表格
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

11 Best PHP URL Shortener Scripts (Free and Premium) 11 Best PHP URL Shortener Scripts (Free and Premium) Mar 03, 2025 am 10:49 AM

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Introduction to the Instagram API Introduction to the Instagram API Mar 02, 2025 am 09:32 AM

Following its high-profile acquisition by Facebook in 2012, Instagram adopted two sets of APIs for third-party use. These are the Instagram Graph API and the Instagram Basic Display API.As a developer building an app that requires information from a

Working with Flash Session Data in Laravel Working with Flash Session Data in Laravel Mar 12, 2025 pm 05:08 PM

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

Build a React App With a Laravel Back End: Part 2, React Build a React App With a Laravel Back End: Part 2, React Mar 04, 2025 am 09:33 AM

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Simplified HTTP Response Mocking in Laravel Tests Simplified HTTP Response Mocking in Laravel Tests Mar 12, 2025 pm 05:09 PM

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

cURL in PHP: How to Use the PHP cURL Extension in REST APIs cURL in PHP: How to Use the PHP cURL Extension in REST APIs Mar 14, 2025 am 11:42 AM

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

12 Best PHP Chat Scripts on CodeCanyon 12 Best PHP Chat Scripts on CodeCanyon Mar 13, 2025 pm 12:08 PM

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Announcement of 2025 PHP Situation Survey Announcement of 2025 PHP Situation Survey Mar 03, 2025 pm 04:20 PM

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio

See all articles