laravelを勉強していた際、以下のコードに「tag('h1','other')」という記述がありました。この部分はPHPの単なる「tag」関数ではないと思うのですが、どのような意味があるのでしょうか?
php
1<?php 2 3namespace App\Http\Controllers; 4 5use Illuminate\Http\Request; 6 7global $head, $style, $body, $end 8$head = '<html><head>'; 9$style = <<<EOF; 10<style> 11 body{font-size:16px; color:#999;} 12 h1{font-size:100pt; text-align:rigth; color:#eee; 13 margin:-40px 0px -50px 0px} 14</style> 15EOF; 16$body = '</head><body>'; 17$end = '</body></head>'; 18 19function tag($tag,$txt){ 20 return "<{$tag}>" . $txt . "</{$tag}>"; 21 22} 23class HelloController extends Controller 24{ 25 public function index() { 26 global $head, $style, $body, $end; 27 28 $html = $head . tag('title', 'Hello/Index') . $style . $body 29 . tag('h1','Index') . tag('p','this is Index page') 30 . '<a href="/hello/other">go to other page</a>' 31 . $end; 32 return $html; 33 34 35 36} 37 38public function other(){ 39 global $head,$style,$body,$end; 40 41 $html = $head . tag('title','Hello/Other') . $style . $body 42 . tag('h1','other') . tag('p','this is other page' 43 . $end; 44 return $html; 45 46 ) 47} 48
回答3件
あなたの回答
tips
プレビュー