Home php教程 php手册 坏狼的PHP学习教程之第2天

坏狼的PHP学习教程之第2天

Jun 13, 2016 pm 12:28 PM
echo php purchase Writing method Basic Study tutorial of virtual host

1.基本写法:

 echo"买虚拟主机找坏狼!www.winshell.cn\n"; 
 //这里是php要写内容! "\n"是代表换行 ";"代表结束 行多的话要加.要不会报错.

2.程式的执:
程式的跑法 由上到下、由右到左,
遇到特殊控制才能回头,
程序停止的方式,跑完结束、错误终止、指令结束.
3.写程序时要注意
不用的变数尽量不要用,例如a=123,但程序用不到,就是浪费了,程序也会变慢.减少测试性写法,减低废码.例如判断对方是男女外星人什么的.
考量程式的弹性(不需要写的都不要用了,方便除错,按tab键换行.同类用同对起.养成良好的写程序习惯.要有规则)
缩排、括弧要对称.  资料量的控制(变数名称的长度,规则短些好)变数例如:aaa.php?id=2222
4.引用档案方式:
require("档案名称"); 引入失败就挂(Error)报错!   好记单词"瑞快尔德"
include("档案名称"); 引入失败就不鸟它(Warning)出个警告! 好记单词"因可入德"
还有其他的require("db.txt"); include("db.txt"); 引用同目录下的db.txt文件.
如果db.txt不存在,require写法会个页面出错。
如果db.txt不存在,include写法只会当前行报错。
5.程式注释
// 单行注释,两撇    /* */ 斜星 - 星斜
/* 这里写要注释的内容,怎么写都行,写多少都行!你看不到我 */
6.常数与变数
常数 ex.例如圆周率  就是平时常见的数,呵呵!
变数 ex. $x, $y, $z..
7.常数的形态
true 真 
fals 假 
8.变数的形态
string 字串
integer 整数 123456780
double 浮点数 有小数点的1.2
array 阵列 
object 物件
9.变数的使用 (\" 变引号 \\反斜线 \n 换行 \r 送出 \t 跳位TAB)
使用保留字
加上$拿去用
形态转换松散
免宣告
有关全域变数 global $变数
10.变数的引号
单引号''没什么作用.
双引号""php帮你处理.
11.$a = "坏狼";
  $b = "卖虚拟主机!";
  echo"$a! $a! 是$b!!!";
12.运算符号
数字、文字、逻辑..
程序重要的一环
理解、查表..
13.算术运算
+加法 -减法 *乘法 /除法 %取余数(8/3余数是2) ++累加1 --递减1
14.字串的运算
.点 =等于
15.设置运算
= 将右边的值连到左边
+= 将右边的值加到左边
-= 将右边的值减到左边
*= 将左边的值乘到右边
/= 将左边的值除到右边
%= 将左边的值对右边取余数
.= 将右边的字串加到左边
今天自己测试写的代码!还要在同目录建立1个db.txt里面写写无聊的东东

复制代码 代码如下:


 
 

 
 买虚拟主机找坏狼 
  
  
  
  require("db.txt"); 
   //引用档案的方式你require("档案内容!"); 如果发现不了档案内容,就会全部停止! 
 echo"
"; 
 //这里显示1个换行
 
   include("db.txt"); 
   //引用档案的方式你include("档案内容!"); 如果发现不了档案内容,只在当行出错误提示! 
   echo"
"; 
   //这里显示1个换行
 
 echo"买虚拟主机找坏狼!
www.winshell.cn\n";  
 //这里是php要写内容! "\n"是代表换行 ";"结束,行多的话要加 
 /* 你看不到我!你看不到我!你看不到我!你看不到我! */ 
  ?> 
  
 
      $a = "坏狼"; 
      $b = "卖虚拟主机的!"; 
 echo"$a! $a! 是$b!!!";  
 echo"
";  
 echo'$a! $a! 是$b!!!//这里是单引号部分,就不做处理了.'; //单引号内不做处理! 
   ?> 
   
 
          $a = "是啊"; 
       $b = "好哦!"; 
       $c = $a . $b ; //把$a和$b的内容加起来成$c 
   echo $c. " 

"; 
      $c = $c . $a .$b; 
   echo $c. "

";      
   ?>     
      $a = "8"; 
   $b = "2"; 
   $c = "3"; 
   echo $a+$b. "
\n"; // 这个\n 查看源文件的时候会看到换行了! 
   echo $a-$b. "
\n"; 
   echo $a*$b. "
\n"; 
   echo $a/$b. "
\n"; 
   echo $a%$b. "
\n"; 
   $a++;  
   echo $a."
\n";   
   $c--;  
   echo $c."
\n"; 
    ?> 
  
 


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 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months 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)

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

In this chapter, we are going to learn the following topics related to routing ?

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

Validator can be created by adding the following two lines in the controller.

CakePHP Working with Database CakePHP Working with Database Sep 10, 2024 pm 05:25 PM

Working with database in CakePHP is very easy. We will understand the CRUD (Create, Read, Update, Delete) operations in this chapter.

See all articles