---
title: "skicka data via en url"
type: "forum-thread"
url: "https://www.webforum.nu/amne/php/77161-skicka-data-via-en-url"
topic: "PHP"
topic_url: "https://www.webforum.nu/amne/php"
author: "mikael_a"
published: "2003-05-16T14:39:06.000Z"
updated: "2003-05-16T21:28:39.000Z"
replies: 4
views: 257
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/php/77161-skicka-data-via-en-url"
---

# skicka data via en url

## #1 — mikael_a, 2003-05-16T14:39Z

hej,

jag skickar med följande data i en url:

	echo "\<a href=\\"main.php?screenWidth=".screen.width. "&screenHeight=".screen.height. "&year=".$year."\\"\>Ej Helskärm\</A\>\<br\>\<br\>";

men screen.width + screen.height skickas inte med...

sedan försöker jag i en javascripts function skicka följande värde:

echo "\<a href=\\"javascript:fullScreen('main.php?screenWidth='+screen.width+'&screenHeight='+screen.height+'&year='$year');\\"\>Helskärm\</A\>\<br\>\<br\>";

då för jag följande fel: ')' behövs...

hatar dessa ' . osv :)

Permalänk: https://www.webforum.nu/p/77161

## #2 — bgust, 2003-05-16T14:44Z

Är screen.width och screen.height variabler bör du klämma in $.

Permalänk: https://www.webforum.nu/p/1050958

## #3 — mikael_a, 2003-05-16T15:39Z

screen.width är inbyggda i java och kollar av bredden... behövs $ då?

Permalänk: https://www.webforum.nu/p/1051008

## #4 — Kent.J, 2003-05-16T16:31Z

Detta kanske hjälper... copy paste från php.net

Om inte annat är det väl alltid bra o veta :)
\-------------------------------

Since Javascript is (usually) a client-side technology, and PHP is (usually) a server-side technology, and since HTTP is a "stateless" protocol, the two languages cannot directly share variables. 

It is, however, possible to pass variables between the two. One way of accomplishing this is to generate Javascript code with PHP, and have the browser refresh itself, passing specific variables back to the PHP script. The example below shows precisely how to do this -- it allows PHP code to capture screen 

```
<?php
if (isset($_GET['width']) AND isset($_GET['height'])) {
  // output the geometry variables
  echo "Screen width is: ". $_GET['width'] ."<br />\n";
  echo "Screen height is: ". $_GET['height'] ."<br />\n";
} else {
  // pass the geometry variables
  // (preserve the original query string
  //   -- post variables will need to handled differently)

  echo "<script language=\"javascript\">\n";
  echo "  location.href=\"${_SERVER['SCRIPT_NAME']}?${_SERVER['QUERY_STRING']}"
            . "&width=\" + screen.width + \"&height=\" + screen.height;\n";
  echo "</script>\n";
  exit();
}
?>
```

Permalänk: https://www.webforum.nu/p/1051050

## #5 — mikael_a, 2003-05-16T21:28Z

tackar...

Permalänk: https://www.webforum.nu/p/1051234

---

Tråden på webben: https://www.webforum.nu/amne/php/77161-skicka-data-via-en-url
