1

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!!

5
  • 2
    How did you expect that header() would work with meta tags? Commented Oct 16, 2014 at 4:22
  • 1
    i am stuck, are you trying to create a new version of php?? Commented Oct 16, 2014 at 4:25
  • 1
    Just do echo '<meta name="viewport" content="width=device-width, initial-scale=1.0">'; ? Commented Oct 16, 2014 at 4:29
  • 1
    The headers you are sending have no whatsoever correlation to the <meta> tags... Commented Oct 16, 2014 at 4:29
  • Ronser, thank you for all that detailed information. For now, I will just use the echo, like you and Shane Smith detailed, since that's the easiest, particularly since this is for a page that's not central to the site (email sent confirmation). I will use your suggestions going forward for other pages. Thank you again! Commented Oct 17, 2014 at 13:50

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.