Php 未在元属性中显示完整url=";og:url";
我试图在og:url的内容中传递函数current_url()中的变量Php 未在元属性中显示完整url=";og:url";,php,codeigniter,metadata,Php,Codeigniter,Metadata,我试图在og:url的内容中传递函数current_url()中的变量 <meta property="og:url" content="[full url here]"> 控制器: public function jobdetails(){ $this->load->library('get_url'); $data['cur_url'] = $this-&
<meta property="og:url" content="[full url here]">
控制器:
public function jobdetails(){
$this->load->library('get_url');
$data['cur_url'] = $this->get_url->current_url();
$this->load->view('head', $data, TRUE);
}
视图:
如$\u服务器['REQUEST\u URI']中所述
返回
为访问此页面而提供的URI;例如,
“/index.html”
您希望添加查询的参数,因此还应该添加query\u字符串
,您可以使用相同的方式访问该字符串:
$_SERVER['QUERY_STRING']
这会回来的
用于访问页面的查询字符串(如果有)
class Get_url{
public function current_url(){
$protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
$url = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
return $url;
}
}
public function jobdetails(){
$this->load->library('get_url');
$data['cur_url'] = $this->get_url->current_url();
$this->load->view('head', $data, TRUE);
}
<meta property="og:url" content="<?php echo $cur_url; ?>">
$_SERVER['QUERY_STRING']