十天学会php之第一天_php基础
以前写了十天学会ASP,十天学会ASP.NET什么的,现在想想再写个PHP吧,也算比较全了。 PHP的调试方法我这里就不说了,外面很多文章都有介绍,也有很多不同的组合。我这里暂时是以 Apache web server 和 MY SQL 作为WEB服务器和数据库,在php-4.3.3下的环境做的程序。当然要简单的构建和访问查看数据库 PHPMYADMIN 不可少。
至于表单设计什么的,我这里也不想多说了,在《十天学会ASP》中已经有介绍。
下面简单介绍一下PHP的语法。
1、嵌入方法:
类似ASP的,当然您也可以自己指定。
2、引用文件:
引用文件的方法有两种:require 及 include。
require 的使用方法如 require("MyRequireFile.php"); 。这个函数通常放在 PHP 程序的最前面,PHP 程序在执行前,就会先读入 require 所指定引入的文件,使它变成 PHP 程序网页的一部份。常用的函数,亦可以这个方法将它引入网页中。
include 使用方法如 include("MyIncludeFile.php"); 。这个函数一般是放在流程控制的处理部分中。PHP 程序网页在读到 include 的文件时,才将它读进来。这种方式,可以把程序执行时的流程简单化。
3、注释方法:
echo "这是第一种例子。
" ; // 本例是 C++ 语法的注释
/* 本例采用多行的
注释方式 */
echo "这是第二种例子。
" ;
echo "这是第三种例子。
" ; # 本例使用 UNIX Shell 语法注释
?>
4、变量类型:
$mystring = "我是字符串" ;
$NewLine = "换行了
" ;
$int1 = 38 ;
$float1 = 1.732 ;
$float2 = 1.4E+2 ;
$MyArray1 = array( "子" , "丑" , "寅" , "卯" );
这里引出两个问题,首先PHP变量以$开头,第二PHP语句以;结尾,可能ASP程序员会不适应。这两个遗漏也是程序上大多错误所在。
5、运算符号:
数学运算: 符号 意义
+ 加法运算
- 减法运算
* 乘法运算
/ 除法运算
% 取余数
++ 累加
-- 递减
字符串运算:
运算符号只有一个,就是英文的句号。它可以将字符串连接起来,变成合并的新字符串。类似ASP中的&
$a = "PHP 4" ;
$b = "功能强大" ;
echo $a.$b;
?>
这里也引出两个问题,首先PHP中输出语句是echo,第二类似ASP中的,PHP中也可以=变量? >。
逻辑运算:
符号 意义
> 大于
>= 大于或等于
== 等于
!= 不等于
&& 而且 (And)
and 而且 (And)
|| 或者 (Or)
or 或者 (Or)
xor 异或 (Xor)
! 不 (Not)
今天就说到这里,明天说一下流程控制。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP logging is essential for monitoring and debugging web applications, as well as capturing critical events, errors, and runtime behavior. It provides valuable insights into system performance, helps identify issues, and supports faster troubleshoot

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-

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.

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' =>

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

Alipay PHP...

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.
