---
title: "Print eller echo??"
type: "forum-thread"
url: "https://www.webforum.nu/amne/php/41054-print-eller-echo"
topic: "PHP"
topic_url: "https://www.webforum.nu/amne/php"
author: "Biohaz66"
published: "2002-04-07T20:13:41.000Z"
updated: "2002-04-12T09:02:10.000Z"
replies: 11
views: 459
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/41054-print-eller-echo"
---

# Print eller echo??

## #1 — Biohaz66, 2002-04-07T20:13Z

Newbie...
Vad är skillnaden och vilken skall man använda??

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

## #2 — spango, 2002-04-07T21:15Z

Smaksak. De flesta tycks använda echo. Det finns lite skillnader som man kan läsa om i [manualen](http://se.php.net/manual/en/function.print.php).

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

## #3 — Virrdo, 2002-04-09T20:14Z

Då är jag en av ett fåtal som använder print då.. ;)
Har iofs inte märkt någe skillnad mellan dem, och det står ju knappt någe alls i manuallen, såvitt jag har sett

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

## #4 — patrik2002, 2002-04-09T20:15Z

ja tror att skillnan e att man måste ha paranteser på echo

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

## #5 — Picklezz, 2002-04-09T21:03Z

paranteser???

behöver man ju inte ha  :q  :P

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

## #6 — patrik2002, 2002-04-09T21:14Z

Kanske inte....ja skrev jag TROR

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

## #7 — Fredde Mannen, 2002-04-10T06:56Z

Så här lyder PHP-maualen!

> **echo()** is not actually a function (it is a language construct) so you are not required to use parentheses with it. In fact, if you want to pass more than one parameter to echo, you must not enclose  the parameters within parentheses. It is not possible to use **echo()** in a variable function context, but you can use 
> **print()** instead.

 

Mer får ni läsa [här](http://www.php.net/manual/en/function.echo.php)!

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

## #8 — Picklezz, 2002-04-10T07:38Z

Re: Så här lyder PHP-maualen!

> **echo()** is not actually a function (it is a language construct) so you are not required to use parentheses with it. In fact, if you want to pass more than one parameter to echo, you must not enclose  the parameters within parentheses. It is not possible to use **echo()** in a variable function context, but you can use 
> **print()** instead.

 Någon som kan översätta detta =)

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

## #9 — Fredde Mannen, 2002-04-10T15:33Z

humm..

kolla in ett svar på .... [PHPbuilder.com](http://www.phpbuilder.com/forum/archives/2/2001/12/2/167150) 

Ursäkta Engelskan, men ni förstår säkert!

> echo doesn't need parentheses around its argument(s) (it's not a function) - and if it has more than one argument (unlike print(), it can take more) it \_mustn't have parentheses. It's also equivalent to the '=' in the HTML-escaping idiom. 
> 
> print() is a function and \_does\_ need the parentheses. 
> 
> print() also returns its argument, so you can say $output=print('This is a string I just printed out.');, but why being able to do that might be necessary is anyone's guess.

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

## #10 — nkrantz, 2002-04-11T18:52Z

Om du i PHP vill skriva ut variabler samt text så är det smartare att använda sig av echo *har jag för mig..* 

```php
print "Detta är en texsträng som innehåller en variabel: nämligen ".$variabel.", cool eller?";
```

 

```php
echo "Detta är en texsträng som innehåller en variabel: nämligen $variabel, cool eller?";
```

 

Som ni ser behöver man inte använda sig av ".." då man ska ange variabelnamnet.. smart om man skriver ut mycket variabler.

// Redigering - Hade visst helt fel.. det är om man använder ' istället för " som man måste '..' -a  :x

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

## #11 — Virrdo, 2002-04-12T06:44Z

nkrantz: Spelar absolut ingen roll, det du gjorde med echo fungerar precis likadant och lika bra med print

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

## #12 — spango, 2002-04-12T09:02Z

Skillnaden är den här:

```php
# Funkar:
$write = 'print';
$write('Hoppsansa');
# Funkar inte:
$write = 'echo';
$write('Hoppsansa');
```

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

---

Tråden på webben: https://www.webforum.nu/amne/php/41054-print-eller-echo
