search
Homephp教程php手册PHP学习笔记(一) 简单了解PHP,php学习笔记了解

PHP学习笔记(一) 简单了解PHP,php学习笔记了解

目标规划:

通过第一节课,我们可以了解php环境.

1.环境的认识:

2.访问方法:

3.修改代码及查看.

4.变量的使用

5.代码缩进要有层次关系,而且代码之间最好保留空行

6.变量命名:

7.变量的输出:

8.变量的三种方法:

1.环境的认识:

软件下载地址: http://www.bkjia.com/softs/24445.html

安装教程非常简单,可以自己百度一下

安装之后的目录结构:

2.访问方法:

直接在浏览器输入:localhost 即可访问

3.修改代码及查看.

我们可以修改上面目录www中的index.php

php输出html代码:

<&#63;php
echo "<html>";
echo "Hello world";
echo "/html";

&#63;>

建议写法

<html> <&#63;php echo "hello world";&#63;></html>

4.变量的使用

<&#63;php
 $name="junzaivip";
 
 echo "{$name} is good";
 &#63;>

5.代码缩进要有层次关系,而且代码之间最好保留空行

6.变量命名:

6.1.尽量不要使用中文

6.2.尽量不用数字开头

6.3.尽量不要使用无意义字母

6.4.变量名会区分大小写,函数名不区分大小写,类名也不能区分大小写,干脆变量名和函数全小写。

6.5.变量的定义  定义必须加$

7.变量的输出:

echo $name;

8.变量的三种方法:

echo($name);   //输出变量

var_dump($name);//输出数组,并且打印类型和长度

print_r($name);//输出数组

example:

<&#63;php
  $arr=array("胡军","垒成","大哥");
 print_r($arr);
 var_dump($arr);
 
 &#63;>

显示如下

通过上面的显示,我们可以看出显示非常的不美观,而且不用一阅读,所以格式化输出方案:

<&#63;php
 $arr=array("胡军","垒成","大哥");
 echo "<pre class="brush:php;toolbar:false">";
 print_r($arr);
 echo "
"; ?>

显示结果如下:

 

小知识:

Utf-8 编码时,一个中文字是3个字符

gbk编码时,一个中文是2个字符

怎做一个简单PHP网站

你试试看使用模板吧,所有的界面设计都是针对一个静态网页进行,这个静态网页里面所有你需要的内容都使用PHP的变量(或者你自己规定的其它特殊格式)来代表,设计布局的时候都是对这么静态网页进行操作。

而网站并不直接向外显示网页,网页的所有内容有PHP程序从数据库里面获取,对网页模板里面的变量进行替换后输出。

例如你的首页模板可以命名为index.htm,实际使用index.php来显示首页,PHP的流程是这样的:
//链接数据库,获取各类数据到变量中
$news='例如新闻内容';
//获取模板
$html=file_get_content('index.htm');
//替换模板中的变量
$html=str_replace('--news--',$news,$html);
//输出模板
echo $html;
?>
 

php学习,php连接本地数据库一个简单的留言板功可以,贴出代码为何提交不到数据库中

你的conn.php应该是个mysql数据库的连接库文件. 有了这个文件后你就可以连接上数据库, 是不是? 但是后来为什么要echo $sql, 你应该mysql_query 啊. $result=mysql_query($sql,$conn)or die(mysql_error());
 

Statement
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)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor