当用户代理来自webview android app时,如何隐藏网站标题(div)?

Im working off of an app template that creates a webview for my site. I need a way to hide a div depending on whether of not that user is using my webview android app.

So far I have found the following php code:

if ($_SERVER['HTTP_X_REQUESTED_WITH'] == "com.company.app") {
    echo 'WebView';
} else{
    echo 'Not WebView';
}

With this code what else do I need to add in order to hide a specific div (my header in this case)?

I would recomend using the open source library made available at mobiledetect.net. You can then use their 'magic methods' to determine if your user is on android.

if( $detect->isAndroidOS() ){ }else{ }

From there it's as simple as placing your <div> inside the else, or applying the style to hide your <div>(<style>.divsClass{display:none;}</style>), or by loading an additional JS or CSS file. There are a lot of variations on how... and depending on your specific scenario, the best option might change.