وظيفة highlight_file() في PHP

التعريف والاستخدام

يتم تمييز ملف باستخدام وظيفة highlight_file().

القواعد النحوية

highlight_file(filename,return)
المتغيرات الوصف
filename مطلوب. مسار ملف PHP الذي سيتم تمييزه.
return اختياري. إذا تم تعيينه على true، فإن الوظيفة تعود إلى النص المميز.

الشرح

تعتمد هذه الوظيفة على الألوان المحددة في برنامج التمييز النحوي PHP، لتوليد أو إرجاع ملف يحتوي على filename النصوص بالقواعد النحوية.

عديد من الخوادم تم تكوينها لتشغيل phps يتم معالجة التمييز التلقائي للأسماء النهائية للملفات. على سبيل المثال، عند عرض example.phps، سيتم عرض ملف المصدر المميز بالقواعد النحوية. لإعداد هذه الوظيفة، يرجى إضافة السطر التالي httpd.confالخط المائة

AddType application/x-httpd-php-source .phps

Return Value

if return If the parameter is set to true, the function will return the highlighted code instead of outputting it. Otherwise, if successful, it returns true, and if failed, it returns false.

Tips and Comments

Warning:It should be noted that when using the highlight_file() function, do not leak sensitive information such as passwords or other types of sensitive information due to carelessness, otherwise potential security risks may occur.

Example

"test.php":

<html>
<body>
<?php
highlight_file("test.php");
?>
</body>
</html>

Output:

<html> 
<body> 
<?php 
highlight_file("test.php");
?>
</body> 
</html>

The result in the browser is similar to this:

<html>
<body>
<code>
<span style="color: #000000"><html>
<br />
<body>
<br />
<span style="color: #0000BB"><?php
<br />highlight_file</span>
<span style="color: #007700">(</span>
<span style="color: #DD0000">"test.php"</span>
<span style="color: #007700">);<br /></span>
<span style="color: #0000BB">?><br /></span>
</body>
<br />
</html></span>
</code>
</body>
</html>