ziphem
ziphem

Reputation: 21

php header() syntax for meta name & content

I've been trying to get the php header() to work with the following meta tags:

<meta name="viewport" content="width=device-width, initial-scale=1.0">

and whatever I try, I just cannot get this to work. I'd like to add this in addition to header("refresh: 15; url=/about.html"); - which does work - so that the view is decent on a mobile device.

I'm also curious about:

<meta name="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="HandheldFriendly" content="true" />

In my feeble attempts to get this to work, I've tried adding

header('Cache-Control: no-cache, no-store, must-revalidate');
header("X-UA-Compatible: IE=edge");
header("Content-Type: text/html; charset=utf-8");

thinking this might cause or at least contribute to the problem, but no luck.

I'd greatly appreciate any feedback or suggestions.

Thanks a ton!!

Upvotes: 1

Views: 2281

Answers (1)

Ronser
Ronser

Reputation: 1875

you can use header like

header("refresh: 15; url=/about.html"); //for delay
header("location:about.html");

you cant use

header('Cache-Control: no-cache, no-store, must-revalidate');
header("X-UA-Compatible: IE=edge");
header("Content-Type: text/html; charset=utf-8");

if you want to add meta tag

use:

if(somecondition)
    echo '<meta name="robots" content="index,follow" />';
     // dynamic as follows...
    //echo '<meta name="'.$metaName.', content="'.$metaContent.'"';
else
    echo '<meta name="keywords" content="" />';

if your consideration is to align your site proper in web and mobile devices

@media (min-width: 700px) { your css styles }

@media (min-width: 300px) and (orientation: landscape) {  your css styles  } 

and many more

Upvotes: 1

Related Questions