Open a new window using PHP

Is there a way to open a new window or a new tab using PHP without using JavaScript.

+4
source share
8 answers

No, a window can only be opened by adding the target="_blank" attribute (invalid in the (X) HTML string, but valid in HTML5) or using the JavaSript window.open(url '_blank') .

PHP works on the server side - therefore it can generate HTML or JavaScript, but it cannot directly interact with the client.

+12
source

Short answer: None .

PHP is a server-side language (at least in the context of web development). It absolutely does not control the client side, that is, the browser.

+6
source

Not. PHP is a server-side language, which means that it was completely done with its work before the browser even started showing the page. You need to use Javascript.

+3
source

No no.

+1
source

No, PHP is server-side scripting.

+1
source

PHP is a server-side language that creates all the code that you see on the page when you select "View Source". PHP cannot affect the client by itself; it must do this using a language such as JavaScript.

+1
source

PHP is server-side, as everyone says, but you can add the target="_blank" attribute to your form tag. This does not work on the production server side, but allows you to submit the form to a new window that will be processed on the server.

A clean trick, but 1) is deprecated in HTML Strict and 2) is rarely useful.

+1
source

This answer focuses on How to call a JavaScript function from a PHP stream? ; you can execute this block of code:

 <?php echo "<script> window.open(\"about:blank\"); </script>"; ?> 

Hope this helps!

-1
source

All Articles