当前位置:网站首页>PHP syntax

PHP syntax

2022-06-13 04:32:00 Culvert.

1 php Grammar format

<?php ?>

2 Basic grammar

(1) Output :echo

(2) Defining variables :$ Variable name = value

(3) String splicing .

(4)var_dump( Variable ): Output the data types in the array

(5)print_r( Array ): The output mode of the array

(6)foreach Traversal array :foreach( Array name as Content )

(7) Traversal array output subscript :foreach( Array name as $key=> $value)

(8)get request :$_GET

(9)form attribute :action For the current form Location of data submission

(10)input attribute : Then get the value entered by the user

3 PHP Connect to database

(1) Create database
$con=mysqli_connect(‘localhost’,‘root’,‘lileidb’)

(2) Set encoding
mysqli_query($con,‘set names utf8’)

(3) To write sql sentence
$sql=“insert into userinfo( Field 1, Field 2,…) values( field value , field value )”

(4) perform sql sentence
mysqli_query($con, $sql)

(5) Close the database
mysqli_close($con)

4 SQL sentence

(1) Insert
$sql=“insert into userinfo( Field 1, Field 2,…) values( field value , field value )”

(2) Delete
$sql=“delete from Table name where id= $id”

(3) modify
$sql=“update Table name set Field 1=‘ The new value 1’,…where id= $id”

(4) Inquire about
$sql=“select Information from Table name where Conditions ”

原网站

版权声明
本文为[Culvert.]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202280522367239.html