移动的元标签 - 应该使用吗?(Meta-tags for mobile – should they be used?)
Meta标签“Viewport”,“MobileOptimized”和“HandheldFriendly”可用于向移动设备提供适当格式的HTML内容。 这些标签是好东西吗? 它们在许多情况下看起来很平坦,即使不是特定平台(viewport),它们似乎需要特定于设备的属性才能正常工作。
应该用吗 何时何地使用它们? 有没有替代方案(没有用户代理识别)?
注意:我一直在使用CSS媒体查询来实现移动支持,但这需要一些UAR才能获得优化的字体大小。
Meta-tags "Viewport", "MobileOptimized" and "HandheldFriendly" can be used to provide appropriately formatted HTML-content to mobile devices. Are these tags good things? They seem pretty platform specific in many cases, and even when not platform specific (viewport), they seem to require device specific attributes in order to work properly.
Should they be used? Where and when is it appropriate to use them? Are there alternatives (without user-agent recognition)?
Note: I have been using CSS media queries to achieve mobile-support, but this requires some UAR in order to get optimize font size.
原文:https://stackoverflow.com/questions/1988499
最满意答案
全局变量是不良实践的代名词,我认为你不能让它变得更好
我也认为这个问题是基于意见的。
无论如何
为什么你不这样做
你可以创建一个新的控制器让我们说BaseController
BaseController extends Controller { protected $hodor; public function __construct() { $hodor = 'HOLD THE FREAKIN DOOR'; } }
然后在你的其他控制器中你可以做到这一点
MyOtherController extends BaseController { public function hodor() { echo "today: $this->hodor"; } }
但正如我所说,全局变量被认为是不良做法所以我认为你应该使用会话
我认为你可以使用配置文件或.env
global variable is a synonym for bad practice , i think you can't make it better
i also think that this question is opinion based.
anyway
why you dont do this
you can create a new controller lets say BaseController
BaseController extends Controller { protected $hodor; public function __construct() { $hodor = 'HOLD THE FREAKIN DOOR'; } }
Then in your other controllers you can do this
MyOtherController extends BaseController { public function hodor() { echo "today: $this->hodor"; } }
But as i said Global variables are considered as bad practices so i think You should use sessions
i think you can use a config file or .env
相关问答
更多-
如何在Laravel中设置全局变量(不与迁移混乱)?(How to Set Global Variable in Laravel (Without Messing up with Migrations)?)[2023-12-01]
你可以试试看吗? try { $site_title = Options::where('option_name','site_title')->first(); $site_options['site_title'] = $site_title->option_value; } catch (\Exception $e) { $site_options['site_title'] = 'Site Title'; } Can you use a try catch on it? t ... -
我应该使用全局变量吗?(Should I use global variables?)[2020-11-21]
我不会说你永远不应该使用全局变量,但是: 永远不要使用单身。 这是为什么。 它们很可怕,而且比普通的旧环境要糟糕得多。 “经理”班不好。 他们“管理”什么? 他们如何“管理”它? “经理”类需要被分解成你可以描述的东西。 一旦你找出了“管理”一个对象意味着什么,你可以定义一个或多个具有更好定义职责的对象。 当你使用全局变量时,不要让它们变为可变的。 一个只写全局是可以接受的(考虑一个记录器,你写它,但它的状态永远不会影响应用程序),并且只读全局变量也可以(考虑各种常量永远不会改变,但你经常需要阅读)。 全局 ... -
使用局部变量或结构(更易读和更模块化)。 请注意,您可以将它们作为g_timeout_add_seconds的客户端数据传递,例如作为某个struct的地址。 所以更喜欢第一个版本到第二个版本。 但是,你应该使用calloc初始化data ,然后在Glib事件循环之后free它。 Use local variables or structures (more readable and more modular). Notice that you could pass them, e.g. as the ad ...
-
全局变量是不良实践的代名词,我认为你不能让它变得更好 我也认为这个问题是基于意见的。 无论如何 为什么你不这样做 你可以创建一个新的控制器让我们说BaseController BaseController extends Controller { protected $hodor; public function __construct() { $hodor = 'HOLD THE FREAKIN DOOR'; } } 然后在你的其他控制器中你可以做到 ...
-
Python函数全局变量?(Python function global variables?)[2023-10-29]
如果你想简单地访问一个全局变量,你只需要使用它的名字。 但是,要更改其值,您需要使用global关键字。 例如 global someVar someVar = 55 这将会将全局变量的值更改为55.否则,它将仅将55分配给局部变量。 函数定义列表的顺序并不重要(假设它们不以某种方式相互引用),它们被调用的顺序是。 If you want to simply access a global variable you just use its name. However to change its valu ... -
Laravel - 使模型中的全局变量仅在模型内部使用(Laravel - Make global variable in Model to use only inside the Model)[2022-06-26]
如果您要在一个模型中使用这些变量,请执行以下操作: protected $firstDayThisYear; public function __construct(array $attributes = []) { parent::__construct($attributes); $this->firstDayThisYear = Carbon::create(date('Y'), 1, 1, 0); } 然后使用$this->firstDayThisYear 。 此外,你可以获得 ... -
您可以尝试查看编辑器,以便全局共享所有视图的数据。 public function compose(View $view) { //get value from database $options = Model::where('domain_name', \Request::server("SERVER_NAME"))->get(); //render to view $view->with('options', $options); } $options变量(模型)将在 ...
-
在构造函数中设置变量。 function _construct() { $this->global = "some value";} 所以,你不仅需要一个全局变量,你也希望这个变量也应该被其他路由改变。 实现这一点的一个方法是使用会话。 function a() { session()->put('global_variable', 'set by method a'); //your other logic } 并从方法b ... function b() { //get t ...
-
您可以利用每个节点安排到自己的周期性消息。 把它放在initialize()的最后阶段就可以了。 您可以按照以下方式进行操作: void initialize(int stage) { if (stage == 3) { cMessage *pMsg = new cMessage("myPeriodicMessage"); scheduleAt(simTime()+1.0, pMsg); } } 然后在handleMessage()有: void h ...
-
如何取消设置全局变量。(How to unset global variables.)[2022-02-23]
将它们设置为null或undefined会实现您正在寻找的内容吗? id_p = null; id_c = null; Would setting them to null or undefined accomplish what you're looking for? id_p = null; id_c = null;