-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.php
More file actions
65 lines (64 loc) · 1.42 KB
/
test.php
File metadata and controls
65 lines (64 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/*ob_start();
$header = "Access-Control-Allow-Origin: ".$_SERVER['HTTP_ORIGIN'];
ob_clean();
header('Access-Control-Allow-Credentials:true');
header($header);
//header("Access-Control-Allow-Origin: http://localhost:63342");
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
function sum($n){
if(is_int($n/2)){
$ret = $n/2;
$str = '';
for($i = 0; $i < $ret; $i++){
$str .= '2';
}
echo $str;
}else{
$ret = ($n-1)/2;
$str = '1';
for ($i = 0; $i < $ret; $i++){
$str .= '2';
}
echo $str;
}
}
function get($n){
$n = (string)$n;
$d_n = array();
$len = strlen($n);
for ($i = $len-1; $i >= 0; $i--){
if($n[$i] != 0){
$d_n[] = $n[$i];
}
}
$dn = implode($d_n);
$n = (int)$dn+(int)$n;
echo $n;
}
function avg($s){
$len = strlen($s);
$sum = array();
$j = 1;
for ($i = 0; $i < $len-1; $i++){
if($s[$i] == $s[$i+1]){
$s[$i] = ++$j;
}else{
$sum[] = $s[$i-1];
$j = 1;
if($i == $len-2){
$sum[] = 1;
}
}
}
$avg = 0;
foreach ($sum as $val){
$avg = (int)$avg+(int)$val;
}
$avg = $avg/count($sum);
echo $avg;
}
var_dump($_REQUEST);*/
$str = '这时是一句话';
$str = substr($str, 0, 3) . '...';
echo $str;