情報学部 | 菅沼ホーム | 目次 | 索引 |
$x = "Taro's table"; echo "変換前: ".$x."<BR>\n"; $y = addslashes($x); echo "変換後: ".$y."<BR>\n"; echo "取り除く: ".stripslashes($y)."<BR>\n";
変換前: Taro's table 変換後: Taro\'s table 取り除く: Taro's table
echo "65 は ".chr(65)."<BR>\n"; echo "A は ".ord("A")."<BR>\n";
65 は A A は 65
$keeped_pw = crypt("pass_word"); // 保存されているパスワード $input_pw = "pass_word"; // 入力されたパスワード if (crypt($input_pw, $keeped_pw) == $keeped_pw) echo "パスワードが一致しました";
echo "Output of Test data"."<BR>\n"; echo "Output of ","Test data","<BR>\n"; print "Output of Test data"."<BR>\n";
Output of Test data Output of Test data Output of Test data
echo ltrim(" 1234Output of Test data ")."<BR>\n"; echo ltrim(" 1234Output of Test data ", " 1..4Out")."<BR>\n"; echo rtrim(" 1234Output of Test data ")."<BR>\n"; echo trim(" 1234Output of Test data ")."<BR>\n";
1234Output of Test data <BR> put of Test data <BR> 1234Output of Test data<BR> 1234Output of Test data<BR>
echo nl2br("Output of Test data\n");
Output of Test data<br />
$x = 1234567.89; echo number_format($x)."<BR>\n"; echo number_format($x, 2)."<BR>\n";
1,234,568 1,234,567.89
echo "65 は ".chr(65)."<BR>\n"; echo "A は ".ord("A")."<BR>\n";
65 は A A は 65
echo "Output of Test data"."<BR>\n"; echo "Output of ","Test data","<BR>\n"; print "Output of Test data"."<BR>\n";
Output of Test data Output of Test data Output of Test data
$x = 12345; $y = 12345.678; $z = "abcdefg"; printf("%d ", $x); printf("%.2f ", $y); printf("%s<BR>\n", $z); echo sprintf("%d %.2f %s<BR>\n", $x, $y, $z);
12345 12345.68 abcdefg 12345 12345.68 abcdefg
echo ltrim(" 1234Output of Test data ")."<BR>\n"; echo ltrim(" 1234Output of Test data ", " 1..4Out")."<BR>\n"; echo rtrim(" 1234Output of Test data ")."<BR>\n"; echo trim(" 1234Output of Test data ")."<BR>\n";
1234Output of Test data <BR> put of Test data <BR> 1234Output of Test data<BR> 1234Output of Test data<BR>
$x = 12345; $y = 12345.678; $z = "abcdefg"; printf("%d ", $x); printf("%.2f ", $y); printf("%s<BR>\n", $z); echo sprintf("%d %.2f %s<BR>\n", $x, $y, $z);
12345 12345.68 abcdefg 12345 12345.68 abcdefg
$str = "12345 12345.678 abcdefg"; echo "値の数: ".sscanf($str, "%d %f %s", $x, $y, $z)."<BR>\n"; echo sprintf("%d %f %s<BR>\n", $x, $y, $z); $a = sscanf($str, "%d %f %s"); foreach ($a as $key => $value) echo "キー: ".$key.", 値: ".$value."<BR>\n";
値の数: 3 12345 12345.678000 abcdefg キー: 0, 値: 12345 キー: 1, 値: 12345.678 キー: 2, 値: abcdefg
echo str_pad("Test Data", 15, "*");
Test Data******
echo str_repeat("/*", 10);
/*/*/*/*/*/*/*/*/*/*
echo str_replace("u", "**", "OutPut Data")."<BR>\n"; $x = array("u", "t"); echo str_replace($x, "", "OutPut Data")."<BR>\n"; echo strtr("OutPut Data", "u", "**")."<BR>\n"; $y = array("u" => "*", "t" => "-"); echo strtr("OutPut Data", $y)."<BR>\n";
O**tP**t Data OP Daa O*tP*t Data O*-P*- Da-a
echo str_shuffle("abcdefg");
ebcdfga
echo strcasecmp("test Output", "test output")."<BR>\n"; echo strcmp("test Output", "test output")."<BR>\n"; echo strncasecmp("test Output", "test output", 4)."<BR>\n"; echo strncmp("test Output", "test output", 4)."<BR>\n";
0 -1 0 0
echo strcasecmp("test Output", "test output")."<BR>\n"; echo strcmp("test Output", "test output")."<BR>\n"; echo strncasecmp("test Output", "test output", 4)."<BR>\n"; echo strncmp("test Output", "test output", 4)."<BR>\n";
0 -1 0 0
echo strip_tags("<B>Output</B> data<BR>\n");
Output data
$x = "Taro's table"; echo "変換前: ".$x."<BR>\n"; $y = addslashes($x); echo "変換後: ".$y."<BR>\n"; echo "取り除く: ".stripslashes($y)."<BR>\n";
変換前: Taro's table 変換後: Taro\'s table 取り除く: Taro's table
echo stristr("Output data1, Data2, Data2", "Data")."<BR>\n"; echo strstr("Output data1, Data2, Data3", "Data")."<BR>\n"; echo strrchr("Output data1, Data2, Data3", "D")."<BR>\n"; echo strpos("Output data1, Data2, Data3", "Data")."<BR>\n"; echo strrpos("Output data1, Data2, Data3", "Data")."<BR>\n";
data1, Data2, Data2 Data2, Data3 Data3 14 21
echo strlen("Output data");
11
echo strcasecmp("test Output", "test output")."<BR>\n"; echo strcmp("test Output", "test output")."<BR>\n"; echo strncasecmp("test Output", "test output", 4)."<BR>\n"; echo strncmp("test Output", "test output", 4)."<BR>\n";
0 -1 0 0
echo strcasecmp("test Output", "test output")."<BR>\n"; echo strcmp("test Output", "test output")."<BR>\n"; echo strncasecmp("test Output", "test output", 4)."<BR>\n"; echo strncmp("test Output", "test output", 4)."<BR>\n";
0 -1 0 0
echo stristr("Output data1, Data2, Data2", "Data")."<BR>\n"; echo strstr("Output data1, Data2, Data3", "Data")."<BR>\n"; echo strrchr("Output data1, Data2, Data3", "D")."<BR>\n"; echo strpos("Output data1, Data2, Data3", "Data")."<BR>\n"; echo strrpos("Output data1, Data2, Data3", "Data")."<BR>\n";
data1, Data2, Data2 Data2, Data3 Data3 14 21
echo stristr("Output data1, Data2, Data2", "Data")."<BR>\n"; echo strstr("Output data1, Data2, Data3", "Data")."<BR>\n"; echo strrchr("Output data1, Data2, Data3", "D")."<BR>\n"; echo strpos("Output data1, Data2, Data3", "Data")."<BR>\n"; echo strrpos("Output data1, Data2, Data3", "Data")."<BR>\n";
data1, Data2, Data2 Data2, Data3 Data3 14 21
echo strrev("Output data");
atad tuptuO
echo stristr("Output data1, Data2, Data2", "Data")."<BR>\n"; echo strstr("Output data1, Data2, Data3", "Data")."<BR>\n"; echo strrchr("Output data1, Data2, Data3", "D")."<BR>\n"; echo strpos("Output data1, Data2, Data3", "Data")."<BR>\n"; echo strrpos("Output data1, Data2, Data3", "Data")."<BR>\n";
data1, Data2, Data2 Data2, Data3 Data3 14 21
echo stristr("Output data1, Data2, Data2", "Data")."<BR>\n"; echo strstr("Output data1, Data2, Data3", "Data")."<BR>\n"; echo strrchr("Output data1, Data2, Data3", "D")."<BR>\n"; echo strpos("Output data1, Data2, Data3", "Data")."<BR>\n"; echo strrpos("Output data1, Data2, Data3", "Data")."<BR>\n";
data1, Data2, Data2 Data2, Data3 Data3 14 21
$x = strtok("Output data1, Data2, Data2", " ,"); while ($x) { echo $x."<BR>\n"; $x = strtok(" ,"); }
Output data1 Data2 Data2
echo strtolower("Output data")."<BR>\n"; echo strtoupper("Output data")."<BR>\n";
output data OUTPUT DATA
echo strtolower("Output data")."<BR>\n"; echo strtoupper("Output data")."<BR>\n";
output data OUTPUT DATA
echo str_replace("u", "**", "OutPut Data")."<BR>\n"; $x = array("u", "t"); echo str_replace($x, "", "OutPut Data")."<BR>\n"; echo strtr("OutPut Data", "u", "**")."<BR>\n"; $y = array("u" => "*", "t" => "-"); echo strtr("OutPut Data", $y)."<BR>\n";
O**tP**t Data OP Daa O*tP*t Data O*-P*- Da-a
echo substr("Output data", 3, 7);
put dat
echo ltrim(" 1234Output of Test data ")."<BR>\n"; echo ltrim(" 1234Output of Test data ", " 1..4Out")."<BR>\n"; echo rtrim(" 1234Output of Test data ")."<BR>\n"; echo trim(" 1234Output of Test data ")."<BR>\n";
1234Output of Test data <BR> put of Test data <BR> 1234Output of Test data<BR> 1234Output of Test data<BR>
情報学部 | 菅沼ホーム | 目次 | 索引 |