php-tidyの読み方

php-tidyの読み方

htmlの修正を行ってくれる「php-tidy」の読み方を掲載してます。

読み⽅

ピーエイチピー・ティディ」と読みます。

英訳

「整理整頓」という意味があります。

php-tidyとは

インストールするとphpでhtmlのコードを整形してくれるソフト

centos8での利用方法は、まずtidyをインストールして

sudo dnf install php-tidy

apacheを再起動すれば、利用できるようになります。

sudo systemctl restart httpd

tidyサンプルコード

<?php
ini_set('display_errors', "On");

$html = '<p>テストHTML';

$config = array('doctype' => 'auto','indent' => true,'wrap' => 200);

$tidy = tidy_parse_string($html, $config, 'UTF8');
$h = tidy_get_html($tidy);

$html = $h->value;

echo $html;