php学习随记一
php学习随记1
<?php # 1. Hello World header("Content-type:text/html;charset=utf-8");#解决中文乱码 echo "hello world"; # 2. 变量 字符串啥的 #必须是$符号开头 用的时候也要带这个他 $a = 1; $b = 3; $c = $a + $b; echo "\n$c"; #据说双引号里的变量名称会被替换成实际值 echo '\n$c'; #单引号还不支持转义字符!! echo "<br>第一个换行"; echo '<br>第二个换行'; # 你好 <br> 然而并不好std; #数组 $arr1 = array('你','好'); echo "<br>$arr1[1]"; $arr2 = array(0=>'n'); echo "<br>$arr2[0]"; #常量 define('Bitch', 111); echo "<br>".Bitch.$arr2[0]; #用.来连接字符串和变量 echo "<br>".__FILE__;#php提供了几个常量 这个是其中一个 #变量的作用域 # 1)函数内部的作用域就是函数 # 2)函数外部的是整个php 但是用户自定义的函数无法使用 # 要想使用必须使用 $heng = 'ha'; function hello(){ global $heng; echo "<br>".$heng; } hello(); #动态变量 #并不是我想的那样 /* $a1 = 1; $b1 = $a1; echo "<br>".$b1; $a1 = 2; echo "<br>".$b1; */ $chang_name = "trans"; $trans = 'You can see me'; echo "<br>$chang_name----$$chang_name"; #php内置好多预定义的变量 使用前必须先赋值给一个我们自己定义的 #变量才能用 参考 http://php.net/manual/zh/reserved.variables.php $host = $_SERVER['HTTP_HOST']; echo "<br>$host"; #字符串运算符 #只有.这一个运算符号 不能使用加号 echo "<br>$a"."$b";//13 echo "<br>".("$a"+"$b");//4 #连接字符 $a.=$b;#相当于 $a = $a.$b; echo "<br>".$a; #逻辑运算 && = and, || = or,异或运算xor 一真一假 则为 真 if ($a and $b) { echo "<br>条件成立"; } [email protected] $worry = @(5 / 0); #php函数 类似于javascript function HelloWorld(){ echo "<br><b>nihao</b>"; } HelloWorld(); #引用传值 和c++一样 默认参数 和c一样 $a10 = 8; function zijia(&$a){ $a += 10; } zijia($a10); echo "<br>$a10"; #支持变量函数 所谓变量函数就是使用变量名字调用函数 $func = "HelloWorld"; $func(); #对函数的引用的就是对函数返回值的应用 function h(){ return "HelloWorld"; } $aaaa = h(); echo "<br>".$aaaa; #声明一个引用类型的函数 #发现引用函数不能直接返回一个常量 #所以 可以预见的是它返回的是一个变量的 #地址 而不是copy一个值直接复制给接收的变量 function &hh(){ $str = "HelloWorld"; return $str; } $bbbb = &hh(); echo "<br>$bbbb"; #当引用结束的时候可以通过unset()来解除引用 #php命名规范 #类名使用驼峰法 #类属性前面就前缀m #类的方法命名 一般规律前缀如 IS Get Set #变量使用小驼峰命名 #引用变量要有前缀r 全局变量有加g前缀 静态变量使用s前缀 #变量分割使用_ #方法,类在不是用_ 而是使用大小写就可以了 #php流程控制语句 和其他语言一样 多出了一个foreach() #类似于java的增强for循环 #在一个复杂的php页面中可能包含多个条件语句,循环语句 #和函数 使用{}会很麻烦 所以php提供了另外一个方式 使用":" #代替"{",使用"end*"代替"}" #支持endif,endwhile,endfor,endreach,endswitch $s = 1; echo "<br>"; while($s++ "; endwhile; ?>
- 2楼shamingai3小时前
- hello world
- Re: u0132241483小时前
- 回复shamingainHello Girl
- Re: shamingai3小时前
- 回复u013224148n哈哈哈,幸会幸会
- Re: u0132241483小时前
- 回复shamingain幸会幸会!能遇到程序媛不容易!
- Re: shamingai2小时前
- 回复u013224148n是么?那我偷偷跟你讲,在我博客下评的好多是妹子
- 1楼u0132241483小时前
- Hello Girl

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

Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

Why Snipping Tool Not Working on Windows 11 Understanding the root cause of the problem can help find the right solution. Here are the top reasons why the Snipping Tool might not be working properly: Focus Assistant is On: This prevents the Snipping Tool from opening. Corrupted application: If the snipping tool crashes on launch, it might be corrupted. Outdated graphics drivers: Incompatible drivers may interfere with the snipping tool. Interference from other applications: Other running applications may conflict with the Snipping Tool. Certificate has expired: An error during the upgrade process may cause this issu simple solution. These are suitable for most users and do not require any special technical knowledge. 1. Update Windows and Microsoft Store apps

In today's era of rapid technological development, programming languages are springing up like mushrooms after a rain. One of the languages that has attracted much attention is the Go language, which is loved by many developers for its simplicity, efficiency, concurrency safety and other features. The Go language is known for its strong ecosystem with many excellent open source projects. This article will introduce five selected Go language open source projects and lead readers to explore the world of Go language open source projects. KubernetesKubernetes is an open source container orchestration engine for automated

"Go Language Development Essentials: 5 Popular Framework Recommendations" As a fast and efficient programming language, Go language is favored by more and more developers. In order to improve development efficiency and optimize code structure, many developers choose to use frameworks to quickly build applications. In the world of Go language, there are many excellent frameworks to choose from. This article will introduce 5 popular Go language frameworks and provide specific code examples to help readers better understand and use these frameworks. 1.GinGin is a lightweight web framework with fast

Part 1: Initial Troubleshooting Steps Checking Apple’s System Status: Before delving into complex solutions, let’s start with the basics. The problem may not lie with your device; Apple's servers may be down. Visit Apple's System Status page to see if the AppStore is working properly. If there's a problem, all you can do is wait for Apple to fix it. Check your internet connection: Make sure you have a stable internet connection as the "Unable to connect to AppStore" issue can sometimes be attributed to a poor connection. Try switching between Wi-Fi and mobile data or resetting network settings (General > Reset > Reset Network Settings > Settings). Update your iOS version:

With the development of the Internet and the advancement of information technology, the era of big data has arrived, and fields such as data analysis and machine learning have also been widely used. In these fields, task scheduling is an inevitable problem. How to achieve efficient task scheduling is crucial to improving efficiency. In this article, we will introduce how to use Golang's web framework Echo framework to implement distributed task scheduling. 1. Introduction to the Echo framework Echo is a high-performance, scalable, lightweight GoWeb framework. It is based on HTTP

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

Laravel is a popular PHP framework that is highly scalable and efficient. It provides many powerful tools and libraries that allow developers to quickly build high-quality web applications. Among them, LaravelEcho and Pusher are two very important tools through which WebSockets communication can be easily implemented. This article will detail how to use these two tools in Laravel applications. What are WebSockets? WebSockets
