[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
test03.php
<?php
echo str_replace("java","PHP","Hello, java world");
?>
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>PHPエラーコード変換</title>
<link rel="stylesheet" href="test1.css">
</head>
<body>
<h1>phpのエラーメッセージを入力してね</h1>
<form action="mytest01.php" method="get">
<p><input type="textarea" name="hoge" value=""></p>
<button type="submit">send</button>
</form>
</body>
</html>
mytest01.php
<?php
$msg = $_GET["hoge"];
//print_r($msg);
//指定した文字列が一致したら置き換える
$foo=htmlspecialchars($msg,ENT_QUOTES);
$replace = str_replace('Parse error: syntax error', 'あるべき文字が抜けているようだ!', $foo);
$replace = str_replace('Undefined variable', 'ごめんよこの変数見つからないや→', $foo);
//$replace = str_replace('on line', '行数はここだ→', $foo);
//受け取った文字列に,があると認識されなくなる。どうしたらいいかな?
?>
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>PHPエラーコード変換</title>
<link rel="stylesheet" href="test1.css">
</head>
<body>
<h1>エラーコードを変換しました!</h1>
<div class="proto">
<h2><?php echo ("原文"); ?></h2>
<p class="foo"><?php echo $msg; ?></p>
</div>
<div class="arrow"><p>↓</p></div>
<div class="trans">
<h2><?php echo ("変換後"); ?></h2>
<p class="foo"><?php echo $replace; ?></p>
</div>
</body>
</html>
test1.css
body{
width:90%;
margin: 0 auto;
}
input{
width:90%;
margin:auto 0;
height:3rem;
}
.proto p{
color:#ccc;
}
h1{
font-size:1.5rem;
}
.proto h2{
font-size:1rem;
background: #eff;
}
.trans h2{
font-size:1rem;
background: #fee;
}
.proto{
padding: 0;
}
.trans{
padding: 0;
}
.foo{
border:solid 1px #ccc;
border-radius: 3rem;
padding:1.5rem;
}
.arrow{
text-align:center;
font-size: 1.2rem;
color:#ccc;
font-weight:bold;
}