PHP - open link in new window?

Sorry if this is clearly obvious, but I have Googled this, and I seriously cannot find any PHP-the only way to do this.

Without using HTML or Javascript - only pure PHP (from the Controller file on the CodeIgniter website) - how can I open a browser window with the link that I specify?

Is it possible?

Thank!

Jack

Edit: It seems that some people misinterpret what I mean, apologize for not clarifying the situation clearly enough. I know with PHP, you can set the header("Location: http://site.com")browser to load a new window; I wanted to know if a headline could be sent to say "open Locationin a new window."

Edit 2: to clarify what I want to do: the user can send something to my site. Before clicking "Submit", they can select (via the check box) in Tweet about it. If a checkmark is checked, after everything is inserted into the database, etc., a new window / tab will load with a URL http://twitter.com/home?status=Hello%20Worldor any tweet. The user decided to do this, so I'm not "doing what I shouldn't." I understand in retrospect that probably the best way to do this.

+3
source share
8 answers

You cannot use server-side language (PHP) to control client-side behavior (forcing a new browser window for a hyperlink).

+10
source

Codeigniter , ,

anchor_popup()

anchor(), , URL- . JavaScript , . , .

URL

+5

codeigniter, URL-. HTML-.

: http://codeigniter.com/user_guide/helpers/url_helper.html

, URL config/autoload.php

 $this->load->helper('url');


 echo anchor('http://your.link.com/whatever', 'title="My News"', array('target' => '_blank', 'class' => 'new_window'));
+4

html codeigniter url, .

  • html.

  • php Codeigniter,

  • php Codeigniter,

$attributes= { 'width' = > '800', 'height' = > '600', 'scrollbars' = > 'yes', 'status' = > 'yes', 'resizable' = > 'yes' }


1. <a href="http://www.google.com" target="_blank">Google</a>

2. <?php echo anchor(prep_url('www.google.com'), 'Google', 'target="_blank"'); ?>

3. <?php echo anchor_popup(prep_url('www.google.com'), 'Google', '$attributes'); ?>
+3

PHP, HTML, :

<?php
echo "<a href=\"some link here\" target=\"_blank\">";
?>

php-:

<a href="some link here" target="_blank">
+1

, echo, php, html , , - .

+1

"", , .

:

:  

  anchor('news/external_link/'.$link['id'], 'target="_blank"');

:  

  function external_link($id)
  {
     $url = $this->model->urls_model->get_url($id);

      redirect(.$url); 
 } 

>

In this example, “target blank” causes the URL to open in a new tab. You can specify a new window if you wish. Hope this helps

+1
source

I know this is a really old article, but I just recently searched for this exact thing.

Codeigniter has a very similar function, anchor()called anchor_popup(), which opens the target in a new window.

http://www.codeigniter.com/user_guide/helpers/url_helper.html?highlight=anchor_popup#anchor_popup

+1
source

Source: https://habr.com/ru/post/1759014/


All Articles