原创 require、require_once、include、include_once區別

require_once 和 include_once 在執行時只對包含的文件執行一次,即使在代碼中調用多次。 include和include_once若包含失敗,顯示警告錯誤(warning error),然後繼續執行。 r

原创 php實現數據結構線性表(鏈式)

<?php class LinkList{ private $head; private $size; private $list; public function __construct()

原创 線程安全和可重入的區別

源出處:http://waret.iteye.com/blog/744169 線程安全函數 概念: 線程安全的概念比較直觀。一般說來,一個函數被稱爲線程安全的,當且僅當被多個併發線程反覆調用時,它會一直產生正確的結果

原创 第一個只出現一次的字符

在一個字符串(1<=字符串長度<=10000,全部由字母組成)中找到第一個只出現一次的字符,並返回它的位置 <?php function FirstNotRepeatingChar($str) { if (!isset(

原创 PHP date()獲取系統時間不對怎麼辦?

使用PHP獲取系統時間,發現時間不對,是因爲PHP默認的時區是UTC,應該將其時區設置爲北京時間。 方法一:修改php.ini文件 打開php.ini文件:鼠標左鍵點擊右下角的WampServer圖標——PHP——php.in

原创 Python坑之——默認參數必須指向不變對象

原文地址:廖雪峯的Python教程——函數的參數 先定義一個函數,傳入一個list,添加一個END再返回: def add_end(L=[]): L.append('END') return L 當你正常調用時,

原创 Leetcode 1. Two Sum

Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may a

原创 把數組排成最小的數

輸入一個正整數數組,把數組裏所有數字拼接起來排成一個數,打印能拼接出的所有數字中最小的一個。例如輸入數組{3,32,321},則打印出這三個數字能排成的最小數字爲321323。 <?php function PrintMinNu

原创 PHP解耦的三重境界(服務容器)

第一重境界 假設場景:我們需要寫一個處理類,能夠同時操作會話,數據庫和文件系統。我們或許會這麼寫。 境界特徵:可以運行,但是嚴重耦合 <?php /** * 第一重 */ namespace test1; class DB

原创 尾遞歸優化

原文地址:廖雪峯的Python教程——遞歸函數 階乘 def fact(n): if n==1: return 1 return n * fact(n - 1) 使用遞歸函數需要注意防止棧溢出。在

原创 PHP實現雙端隊列

PHP實現隊列:第一個元素作爲隊頭,最後一個元素作爲隊尾 <?php $array = array('PHP', 'JAVA'); array_push($array, 'PYTHON'); //入列 array_shift($a

原创 Python 一行代碼可以做的事

求1到10中所有偶數的平方 L=[i*i for i in range(1,11) if i%2==0] print(L) 生成全排列 L=[m+n for m in 'ABC' for n in 'XYZ'] print

原创 PHP實現排列組合

<?php // 階乘 function factorial($n){ return array_product(range(1,$n)); } // 排列數 function A($n,$m){ return

原创 phpStorm problems with php-cgi

php-cgi not found 解決辦法 on linux ubuntu For PHP5:sudo apt-get install php5-cgi For PHP7:sudo apt-get install php

原创 python所有庫

http://www.lfd.uci.edu/~gohlke/pythonlibs/ 搜索需要的庫,點擊下載,將後綴改爲zip並解壓。 將解壓後的文件夾複製到python安裝目錄的lib文件夾下。 點贊 收