无需言 做自己 业 ,精于勤 荒于嬉.

docker docker-compose

发表日期:2021-07-26 23:28:47 | 来源: | 分类:docker

      示例1
nginx:
    build: ./nginx
    volumes: 
        - /home/eniac/Desktop/docker-test/nginx/html:/usr/local/nginx/html
        - /home/eniac/Desktop/docker-test/nginx/conf:/usr/local/nginx/conf
        - /home/eniac/Desktop/docker-test/nginx/logs:/usr/local/nginx/logs
    ports: 
        - "8082:80"
    links: 
        - php
php:
    build: ./php
    volumes:
        - /home/eniac/Desktop/docker-test/nginx/html:/var/www/html
        - /home/eniac/Desktop/docker-test/php:/usr/local/etc/php
    ports: 
        - "9000:9000"

阅读全文 »

docker docker-mysql

发表日期:2021-07-26 23:28:27 | 来源: | 分类:docker

      示例1
mysql 

#docker run -it --entrypoint /bin/bash --rm mysql:5.6 (创建并进入容器里,方便查看容器里面的默认设置,--rm参数表示退出容器会自动删除当前容器)


docker run --privileged=true -p 3306:3306 --name mysql \
-v /media/eniac/娱乐/docker/mysql/logs:/var/log/mysql \
-v /media/eniac/娱乐/docker/mysql/data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=123456 \
-d mysql:5.6

docker container ls

docker exec -it mysql bash


挂载了配置就不能正常挂载数据了。。
-v /media/eniac/娱乐/docker/mysql/conf:/etc/mysql/mysql.conf.d \

阅读全文 »

页面相关 replaceAll 实现字符串替换全部方法

发表日期:2021-07-01 15:08:40 | 来源: | 分类:页面相关

      示例1
//最新的谷歌等浏览器内核内置了replaceAll 方法,如果没有的话使用自己实现的
if (typeof String.prototype.replaceAll !== "function"){
    String.prototype.replaceAll = function (reg, str) {
        var flags = 'g';
        if (Object.prototype.toString.call(reg).toLowerCase() === '[object regexp]') {
            // 传入的是正则
            if (reg.global) {
                return this.replace(reg, str);
            } else {
                flags += (reg.ignoreCase ? 'i' : '') + (reg.multiline ? 'm' : '');
                reg = reg.source;// 获取正则源码
            }
        } else {
            reg = reg.replace(/([\*\[\]\{\}\-])/g, "\\$1");
        }
        return this.replace(new RegExp(reg, flags), str);
    }
}

阅读全文 »

字符串 函数 ucfirst 将字符串的首字母转换为大写

发表日期:2021-07-01 10:23:26 | 来源: | 分类:字符串 函数

      示例1
<?php 
$foo = 'hello world!';
$foo = ucfirst($foo);
// Hello world!
$bar = 'HELLO WORLD!';
$bar = ucfirst($bar);
// HELLO WORLD!
$bar = ucfirst(strtolower($bar));
// Hello world!
?>

阅读全文 »

字符串 函数 ucwords 将字符串中每个单词的首字母转换为大写

发表日期:2021-07-01 10:23:26 | 来源: | 分类:字符串 函数

      示例1
<?php 
$foo = 'hello world!';
$foo = ucwords($foo);
// Hello World!
$bar = 'HELLO WORLD!';
$bar = ucwords($bar);
// HELLO WORLD!
$bar = ucwords(strtolower($bar));
 // Hello World!
 ?>
      示例2
<?php 
$foo = 'hello|world!';
$bar = ucwords($foo);
// Hello|world!
$baz = ucwords($foo, "|");
// Hello|World!
?>

阅读全文 »

字符串 函数 vfprintf 将格式化字符串写入流

发表日期:2021-07-01 10:23:26 | 来源: | 分类:字符串 函数

      示例1
<?php 
if (!($fp = fopen('date.txt', 'w')))    return;
vfprintf($fp, "%04d-%02d-%02d", array($year, $month, $day));
// 将向 date.txt 写入格式化的 ISO 标准日期
?>

阅读全文 »

字符串 函数 vprintf 输出格式化字符串

发表日期:2021-07-01 10:23:26 | 来源: | 分类:字符串 函数

      示例1
<?php 
vprintf("%04d-%02d-%02d", explode('-', '1988-8-1'));
 // 1988-08-01
 ?>

阅读全文 »

字符串 函数 substr 返回字符串的子串

发表日期:2021-07-01 10:23:26 | 来源: | 分类:字符串 函数

      示例1
<?php 
$rest = substr("abcdef", -1);
    // 返回 "f"$rest = substr("abcdef", -2);
    // 返回 "ef"$rest = substr("abcdef", -3, 1);
 // 返回 "d"?>
      示例2
<?php 
$rest = substr("abcdef", 0, -1);
  // 返回 "abcde"$rest = substr("abcdef", 2, -1);
  // 返回 "cde"$rest = substr("abcdef", 4, -4);
  // 返回 ""$rest = substr("abcdef", -3, -1);
 // 返回 "de"?>
      示例3
<?php 
echo substr('abcdef', 1);
// bcdefecho substr('abcdef', 1, 3);
// bcdecho substr('abcdef', 0, 4);
// abcdecho substr('abcdef', 0, 8);
// abcdefecho substr('abcdef', -1, 1);
// f// 访问字符串中的单个字符
// 也可以使用中括号
$string = 'abcdef';
echo $string[0];
// aecho $string[3];
// decho $string[strlen($string)-1];
// f
?>
      示例4
<?php 
class apple {
    public function __toString() {
        return "green";
    }
}
echo "1) ".var_export(substr("pear", 0, 2), true).PHP_EOL;
echo "2) ".var_export(substr(54321, 0, 2), true).PHP_EOL;
echo "3) ".var_export(substr(new apple(), 0, 2), true).PHP_EOL;
echo "4) ".var_export(substr(true, 0, 1), true).PHP_EOL;
echo "5) ".var_export(substr(false, 0, 1), true).PHP_EOL;
echo "6) ".var_export(substr("", 0, 1), true).PHP_EOL;
echo "7) ".var_export(substr(1.2e3, 0, 4), true).PHP_EOL;
?>
      示例5
<?php 
var_dump(substr('a', 2));
 // bool(false)
?>

阅读全文 »

字符串 函数 vsprintf 返回格式化字符串

发表日期:2021-07-01 10:23:26 | 来源: | 分类:字符串 函数

      示例1
<?php 
print vsprintf("%04d-%02d-%02d", explode('-', '1988-8-1'));
?>

阅读全文 »

字符串 函数 wordwrap 打断字符串为指定数量的字串

发表日期:2021-07-01 10:23:26 | 来源: | 分类:字符串 函数

      示例1
<?php 
$text = "The quick brown fox jumped over the lazy dog.";
$newtext = wordwrap($text, 20, "<br />\n");
echo $newtext;
?>

      示例2
<?php 
$text = "A very long woooooooooooord.";
$newtext = wordwrap($text, 8, "\n", true);
echo "$newtext\n";
?>

      示例3
<?php 
$text = "A very long woooooooooooooooooord. and something";
$newtext = wordwrap($text, 8, "\n", false);
echo "$newtext\n";
?>

阅读全文 »

字符串 函数 strpbrk 在字符串中查找一组字符的任何一个字符

发表日期:2021-07-01 10:23:25 | 来源: | 分类:字符串 函数

      示例1
<?php 
$text = 'This is a Simple text.';
// 输出 "is is a Simple text.",因为 'i' 先被匹配echo strpbrk($text, 'mi');
// 输出 "Simple text.",因为字符区分大小写echo strpbrk($text, 'S');
?>

阅读全文 »

字符串 函数 stripslashes 反引用一个引用字符串

发表日期:2021-07-01 10:23:25 | 来源: | 分类:字符串 函数

      示例1
<?php 
$str = "Is your name O\'reilly?";
// 输出: Is your name O'reilly?echo stripslashes($str);
?>

      示例2
<?php 
function stripslashes_deep($value){
    $value = is_array($value) ?                array_map('stripslashes_deep', $value) :                stripslashes($value);
    return $value;
}
// 范例$array = array("f\\'oo", "b\\'ar", array("fo\\'o", "b\\'ar"));
$array = stripslashes_deep($array);
// 输出print_r($array);
?>

阅读全文 »

字符串 函数 strrev 反转字符串

发表日期:2021-07-01 10:23:25 | 来源: | 分类:字符串 函数

      示例1
<?php 
echo strrev("Hello world!");
 // 输出 "!dlrow olleH"?>

阅读全文 »

字符串 函数 strripos 计算指定字符串在目标字符串中最后一次出现的位置(不区分大小写)

发表日期:2021-07-01 10:23:25 | 来源: | 分类:字符串 函数

      示例1
<?php 
$haystack = 'ababcd';
$needle   = 'aB';
$pos      = strripos($haystack, $needle);
if ($pos === false) {
    echo "Sorry, we did not find ($needle) in ($haystack)";
}
 else {
    echo "Congratulations!\n";
    echo "We found the last ($needle) in ($haystack) at position ($pos)";
}
?>

阅读全文 »

字符串 函数 strrpos 计算指定字符串在目标字符串中最后一次出现的位置

发表日期:2021-07-01 10:23:25 | 来源: | 分类:字符串 函数

      示例1
<?php 
$pos = strrpos($mystring, "b");
if ($pos === false) {
 // 注意: 三个等号    // 未发现...}
?>

      示例2
<?php 
$foo = "0123456789a123456789b123456789c";
var_dump(strrpos($foo, '7', -5));
  // 从尾部第 5 个位置开始查找                                   // 结果: int(17)var_dump(strrpos($foo, '7', 20));
  // 从第 20 个位置开始查找                                   // 结果: int(27)var_dump(strrpos($foo, '7', 28));
  // 结果: bool(false)?>

阅读全文 »

字符串 函数 strstr 查找字符串的首次出现

发表日期:2021-07-01 10:23:25 | 来源: | 分类:字符串 函数

      示例1
<?php 
$email  = 'name@example.com';
$domain = strstr($email, '@');
echo $domain;
 // 打印 @example.com$user = strstr($email, '@', true);
 // 从 PHP 5.3.0 起echo $user;
 // 打印 name?>

阅读全文 »

字符串 函数 strtok 标记分割字符串

发表日期:2021-07-01 10:23:25 | 来源: | 分类:字符串 函数

      示例1
<?php 
$string = "This is\tan example\nstring";
/* 使用制表符和换行符作为分界符 */
$tok = strtok($string, " \n\t");
while ($tok !== false) {
    echo "Word=$tok<br />";
    $tok = strtok(" \n\t");
}
?>

      示例2
<?php 
$first_token  = strtok('/something', '/');
$second_token = strtok('/');
var_dump($first_token, $second_token);
?>

阅读全文 »

字符串 函数 strtoupper 将字符串转化为大写

发表日期:2021-07-01 10:23:25 | 来源: | 分类:字符串 函数

      示例1
<?php 
$str = "Mary Had A Little Lamb and She LOVED It So";
$str = strtoupper($str);
echo $str;
 // 打印 MARY HAD A LITTLE LAMB AND SHE LOVED IT SO?>

阅读全文 »

字符串 函数 strpos 查找字符串首次出现的位置

发表日期:2021-07-01 10:23:25 | 来源: | 分类:字符串 函数

      示例1
<?php 
$mystring = 'abc';
$findme   = 'a';
$pos = strpos($mystring, $findme);
// 注意这里使用的是 ===。简单的 == 不能像我们期待的那样工作,// 因为 'a' 是第 0 位置上的(第一个)字符。if ($pos === false) {
    echo "The string '$findme' was not found in the string '$mystring'";
}
 else {
    echo "The string '$findme' was found in the string '$mystring'";
    echo " and exists at position $pos";
}
?>

      示例2
<?php 
$mystring = 'abc';
$findme   = 'a';
$pos = strpos($mystring, $findme);
// 使用 !== 操作符。使用 != 不能像我们期待的那样工作,// 因为 'a' 的位置是 0。语句 (0 != false) 的结果是 false。if ($pos !== false) {
     echo "The string '$findme' was found in the string '$mystring'";
         echo " and exists at position $pos";
}
 else {
     echo "The string '$findme' was not found in the string '$mystring'";
}
?>

      示例3
<?php 
// 忽视位置偏移量之前的字符进行查找$newstring = 'abcdef abcdef';
$pos = strpos($newstring, 'a', 1);
 // $pos = 7, 不是 0?>

阅读全文 »

字符串 函数 substr_count 计算字串出现的次数

发表日期:2021-07-01 10:23:25 | 来源: | 分类:字符串 函数

      示例1
<?php 
$text = 'This is a test';
echo strlen($text);
 // 14echo substr_count($text, 'is');
 // 2// 字符串被简化为 's is a test',因此输出 1echo substr_count($text, 'is', 3);
// 字符串被简化为 's i',所以输出 0echo substr_count($text, 'is', 3, 3);
// 因为 5+10 > 14,所以生成警告echo substr_count($text, 'is', 5, 10);
// 输出 1,因为该函数不计算重叠字符串$text2 = 'gcdgcdgcd';
echo substr_count($text2, 'gcdgcd');
?>

阅读全文 »

全部博文(1580)
集速网 copyRight © 2015-2022 宁ICP备15000399号-1 宁公网安备 64010402001209号
与其临渊羡鱼,不如退而结网
欢迎转载、分享、引用、推荐、收藏。