【玩转微信公众平台之7】 PHP语法简单介绍
【玩转微信公众平台之七】 PHP语法简单介绍
经过多篇的努力,我们终于成为了微信公众平台的开发者。但是别高兴的太早,就跟修真小说一样:修炼多年武破虚空,飞升到仙界后本以为成为了天仙即可跳出三界外,不在五行中。可实际到了仙界才发现,成仙只是修行的第一步......
没错,成为开发者也才只是第一步,因为现在你的微信公众平台还没有任何功能,说难听点就是小白,说好听点就是白马王子,说可爱点就是小白白,说黄色点就是洗白白,说...
----------------
要想在微信公众平台添加功能,那就需要写代码;既然说到写代码,那么肯定是要用php(如果用ASP,Java也可以),既然说到php,那么你肯定要懂得php怎么用吧?如果懂得你可以不用往下看了,如果不懂?走起!
PHP是什么语言?PHP是一种创建爱你动态交互站点的强有力的服务器端脚本语言.......(其他请百度)。
1、首先介绍下php开发的工具,这个有很多选择,像我是直接使用Dreamweaver来开发,这个大家也都比较熟悉。
下载地址为:http://yunpan.cn/QiPjymeWbuceR 访问密码 e7df。安装过程贼简单,直接跳过。
当然了,SAE也提供了代码在线编辑功能,不过相对来说不是很方便。
2、下面简单介绍些php的语法
1)php的代码(脚本块)可以放置在文档的任何位置,但是要有个标志来提醒,这个标志就是以""结束。例如我下面打印一个简单的字符串:hello star
<?phpecho "hello star";?>
2)php的变量。
php中所有的变量都是以 $ 符号开始的,在声明一个变量时不需要明确变量的类型,因为php会自动把变量转换为正确的数据类型。这个与C,Java等语言有很大的差别。如下:
<?php $a = 5;//相当于int a = 5$b = "this is a string";//相当于 string b = "this is a string"?>
3)php的链接操作符。
php中的连接操作符为 "."(一个英文的句号)。它可以连接字符串,当操作数中有非字符串时,会先转换成字符串,然后再将字符串连接起来,如下代码:
<?php $a = 5;$b = 6;$c = "this is a string";echo $a . $b;//输出结果为56echo $a . $c;//输出结果为 5this is a string?>
这个东西说简单也简单,但讲起来有点烦琐,所以直接给个链接自己去看吧。(旁白:博主,为什么你这么懒? 博主:要你管!)
http://www.w3school.com.cn/php/php_operators.asp
5)其实掌握以上几点的话,开发一个简单的微信公众平台还是勉强够看的,剩下的内容推荐大家去w3c是这个网站上学习。上面的教程写的都很棒,是想学好php绝对不能错过的网站!
http://www.w3school.com.cn/php/index.asp
恩,扯到这里,手工!
尊重原创,转载请注明来源:http://blog.csdn.net/star530/article/details/25744137

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.
