How can PHP be used to prevent pages from loading from the cache after logging out?

After logging out of a website, it is important to prevent pages from loading from the cache to ensure that sensitive information is not accessible to unauthorized users. This can be achieved by adding cache control headers to the PHP code, specifically setting the "Cache-Control" and "Expires" headers to prevent caching.

// Prevent pages from loading from the cache after logging out
header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1
header("Pragma: no-cache"); // HTTP 1.0
header("Expires: 0"); // Proxies