PHP基础2
2014-03-17 10:27
369 查看
1. sprintf Replace the percent (%) sign by a variable passed as an argument:
http://www.w3schools.com/php/func_string_sprintf.asp
2. global variable
using global variable inside function
3. print_r
Prints human-readable information about a variable
4. str_word_count
second parameter
0: the number of words
1: put words in array,
2. put words in array, key is the position of the words in the string
the function ignore other character, to not ignore certain character
5. string concatenation
dot
http://www.w3schools.com/php/func_string_sprintf.asp
<?php $number = 9; $str = "Beijing"; $txt = sprintf("There are %u million bicycles in %s.",$number,$str); echo $txt; ?>
2. global variable
using global variable inside function
<?php function echo_ip(){ global $user_ip; $string = "your ip addr is ".$user_ip; echo $string; } echo_ip(); ?>
3. print_r
Prints human-readable information about a variable
<?php $string = 'this is a example string'; $string_word_count = str_word_count($string,1); print_r($string_word_count); ?>
4. str_word_count
second parameter
0: the number of words
1: put words in array,
2. put words in array, key is the position of the words in the string
<?php $string = 'this is a example string'; $string_word_count = str_word_count($string,1); print_r($string_word_count); ?>
the function ignore other character, to not ignore certain character
<?php $string = 'this is a example string , $ &'; $string_word_count = str_word_count($string,1,',&'); print_r($string_word_count); ?>
5. string concatenation
dot
<?php $string1 ='apple '.'banana'; $string2 =' pig'; echo $string1.$string2; ?>
相关文章推荐
- 这回真的是挤时间了-PHP基础(三)
- php基础_数组1(对数组格式的处理)
- PHP 基础—— include 和 require
- html基础 post方式提交数据给后台的php处理
- php新手入门的基础内容③图片上传
- PHP基础系列(一) PHP字符串相关的函数分类整理
- PHP基础错误导致的500
- php从入门到放弃系列-02.php基础语法
- PHP基础
- PHP基础入门(三)
- PHP基础知识点
- php基础概念
- php基础之小菜鸟起飞(一)
- php基础之gd图像生成、缩放、logo水印和简单验证码实现
- PHP学习笔记(二)基础知识结束
- php基础
- PHP 基础知识代码总结
- PHP基础算法
- PHP mysql基础操作
- 《PHP求职宝典》--PHP语言基础笔记3