사이트 내 전체검색
PHP
[php] Html 테이블 테그 만드는 함수
로빈아빠
https://cmd.kr/php/431 URL이 복사되었습니다.

본문

Html 테이블 테그 만드는 함수
 
웹 페이지를 만들다 보면 테이블을 만들어야 할 때가 많은데.
이처럼 빈번히 사용되는 td,tr,table 태그를
함수로 정의해서 사용하면
조금이나마 더 수월하게 테이블을 만들 수 있을 듯 합니다.
소스도 깔끔해지고...

function html_td($content,$width="",$align="",$style="") { 

if (!$content) { 
$content = "표시할 내용이 없습니다!"; 
} 

$td = "<td width=\"$width\" align=\"$align\" $style>\n". 
       "$content". 
       "</td>\n"; 

return $td; 

} 

function html_tr($content) { 

if (!$content) { 
$content = "표시할 내용이 없습니다!"; 
} 

$tr = "<tr>\n". 
       "$content". 
       "</tr>\n"; 

return $tr; 

} 

// html_td 와 html_tr 함께 사용한 것과 같은 효과. 
function html_trtd($content,$width="",$align="",$style="") { 

if (!$content) { 
$content = "표시할 내용이 없습니다!"; 
} 

$result = "<tr>\n". 
             "<td width=\"$width\" align=\"$align\" $style>$content</td>\n". 
             "</tr>\n"; 

return $result; 

} 


function html_table($content,$width="",$align="",$style="") { 

if (!$content) { 
$content = "표시할 내용이 없습니다!"; 
} 

$table = "<table width=\"$width\" align=\"$align\" $style>\n". 
            "$content\n". 
            "</table>\m"; 

return $table; 

}


함수는 간단해서 사용하기는 쉽습니다.
하지만 기능은 막강...

댓글목록

등록된 댓글이 없습니다.

PHP
871 (11/18P)

Search

Copyright © Cmd 명령어 3.22.71.188