如何在開發的過程中加入測試。
- Model
- Repository
- Controller
- Auth
<?php | |
function display_filesize($filesize){ | |
if(is_numeric($filesize)){ | |
$decr = 1024; $step = 0; | |
$prefix = array('Byte','KB','MB','GB','TB','PB'); | |
while(($filesize / $decr) > 0.9){ | |
$filesize = $filesize / $decr; | |
$step++; |
<?php | |
namespace PHP81_BC; | |
/** | |
* Locale-formatted strftime using IntlDateFormatter (PHP 8.1 compatible) | |
* This provides a cross-platform alternative to strftime() for when it will be removed from PHP. | |
* Note that output can be slightly different between libc sprintf and this function as it is using ICU. | |
* | |
* Usage: | |
* use func \PHP81_BC\strftime; |
<?php declare(strict_types=1); | |
use PHPUnit\Framework\TestCase; | |
class DBA | |
{ | |
public function getRowCount($table) | |
{ | |
$pdo = new PDO("mysql:host=localhost;dbname=test",'root',''); | |
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
# 通常建議專案最頂層的配置文件設定該值 | |
root = true | |
# 表示以 Unix 風格的換行符號結尾另外刪除換行字元所有的空白 | |
[*] | |
end_if_line = lf | |
insert_final_newline = true | |
trim_trailing_whitespace = true | |
indent_style = space |
<?php | |
function sMakePageBar($iAllItems,$iPageItems,$iPg=0,$sUrl){ | |
$iPages = 0; | |
$sPageBar = ''; | |
$current = 0; | |
$PHP_SELF = $_SERVER['PHP_SELF']; | |
if ($iPageItems) $iPages = (INT)($iAllItems/$iPageItems); |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Star Rating System</title> | |
<meta name="viewport" content="width=device-width"> | |
<style> | |
.star{ | |
color: goldenrod; | |
font-size: 2.0rem; |
<?php | |
/** | |
* Replace non-breaking spaces with normal spaces | |
* | |
* @param $str | |
* @return string | |
*/ | |
function removeNbsp($str) | |
{ |
<?php | |
/** | |
* php-ansi-color | |
* | |
* Original | |
* https://github.com/loopj/commonjs-ansi-color | |
* | |
* @code | |
* <?php | |
* require_once "ansi-color.php"; |
<?php | |
/** | |
* @desc decorator | |
*/ | |
function save_db($str){ | |
$wrap_func = function() use ($str) { | |
echo "run wrap_func".PHP_EOL; | |
echo "string = $str".PHP_EOL; |