9951 explained code solutions for 126 technologies


php-wordpressHow to add a PHP header in WordPress?


Adding a PHP header in WordPress is a simple process. To do this, you need to use the header() function. This function takes two parameters: the header name and the header value.

<?php
header("Content-Type: text/html; charset=utf-8");
?>

This code will add a header with the name Content-Type and the value text/html; charset=utf-8.

Code explanation

  1. <?php - This is the opening PHP tag.
  2. header() - This is the function used to add a header.
  3. "Content-Type" - This is the header name.
  4. "text/html; charset=utf-8" - This is the header value.
  5. ?> - This is the closing PHP tag.

Helpful links

Edit this code on GitHub