<?php $fname = $_POST["fname"]; $num = mb_strlen($fname, "UTF-8"); $font = $_POST["font"]; $hcolor = $_POST["color"]; // フォントの選択 if ($font == "nikumaru") { $font = "./fonts/nikumaru.otf"; } elseif ($font == "dasaji") { $font = "./fonts/dasaji.ttf"; } // 姓の文字数 if ($num == 1) { $text1 = $fname; name1($font, $hcolor, $text1); } elseif ($num == 2) { $text1 = mb_substr($fname, 0, 1, "UTF-8"); $text2 = mb_substr($fname, 1, 1, "UTF-8"); name2($font, $hcolor, $text1, $text2); } elseif ($num == 3) { $text1 = mb_substr($fname, 0, 1, "UTF-8"); $text2 = mb_substr($fname, 1, 1, "UTF-8"); $text3 = mb_substr($fname, 2, 1, "UTF-8"); name3($font, $hcolor, $text1, $text2, $text3); } elseif ($num == 4) { $text1 = mb_substr($fname, 0, 1, "UTF-8"); $text2 = mb_substr($fname, 1, 1, "UTF-8"); $text3 = mb_substr($fname, 2, 1, "UTF-8"); $text4 = mb_substr($fname, 3, 1, "UTF-8"); name4($font, $hcolor, $text1, $text2, $text3, $text4);
<?php $name3 = "Simon"; $name = "Gord"; function name1($name) { $name = "Aaron"; return "Bob"; } function name2(&$name2) { //global $name2; $name2 = "Ian"; return $name2; } function name3($name3) { echo $name3; } echo "The two names are: " . name1($name) . " and " . name2($name2) . "<br>"; echo "The variables are: " . $name . " " . $name2 . "<br>"; echo name3($name3);