Question about The PHP Group PHP

2 Answers

Echo PHP What is the difference between PHP echo and print?

Posted by on

2 Answers

  • Level 1:

    An expert who has achieved level 1.

    Corporal:

    An expert that has over 10 points.

    Problem Solver:

    An expert who has answered 5 questions.

  • Contributor
  • 8 Answers

Echo is marginally faster than print, and print returns a value, echo does not.

Echo allows comma separated arguments which it will concatenate. Print accepts only a single argument, but this is hardly a deal-breaker, because you can concatenate with a dot anyway.

Echo does not have a place in the precedence table, which means you can't use it in a complex expression.

That said ... for most cases, the major significant difference is:

Echo is quicker to type :)

Posted on Nov 26, 2008

  • Level 2:

    An expert who has achieved level 2 by getting 100 points

    Hot-Shot:

    An expert who has answered 20 questions.

    Corporal:

    An expert that has over 10 points.

    Mayor:

    An expert whose answer got voted for 2 times.

  • Expert
  • 72 Answers

Print outputs a single string, echo can output multiple strings. (It's in the help file.)

Posted on Sep 10, 2008

Add Your Answer

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

1 Answer

Hi, how do i call a javascript function from a separate file from my php file? I do it like this but aint working... php file --------------------- <?php echo "<script...


try this

<html>

<head>

<title>Test</title>

<script src="test.js" type="text/javascript"></script>

</head>

<body>

<?php

echo '<script type="text/javascript">someFunction();</script>';

?>

</body>

</html>


Good Luck

Dec 10, 2010 | The PHP Group PHP

Tip

How to create a batch file on windows xp.


To create a batch file that would be very helpful I suggest downloading notepad++ it's made for programming.First off open up notepad++ and go to
languages and click on batch then type in "@echo off" at the beginning of every batch file you need to type that in.Next type in:
______________________________________________________________

@echo off
echo.
echo What would you like to do today?
echo.
echo 1)Notepad
echo 2)Paint
echo 3)Calculator
echo.

set /p web=Type in Option:
if "%web%"=="1" ("%SystemRoot%\system32\notepad.exe") else (exit)
if "%web%"=="2" ("%SystemRoot%\system32\mspaint.exe") else (exit)
if "%web%"=="3" ("%SystemRoot%\system32\calc.exe") else (exit)

______________________________________________________________

You just created a batch file menu now save this file to the desktop as
"Menu.bat".Now that you have the file saved download this free batch file compiler called "battoexe" so nobody can edit or destroy you batch files.
That's it you have made your first batch file visit my website at www.wix.com/Firestorm002/Batch101.

on Jul 18, 2010 | Compilers & Programming Tools

1 Answer

PHP/SQL Problem


have you read the dataset in (i.e $row)?
you would require some sort of select statement to read the data frm sql into a dataset before yopu can read and display each record in the dataset.

i gather you may be new to sql statements. the bottom commect $query.... is reading the dataset into $query, the one you have issues with needs code that reads a record into $row

Jan 25, 2010 | The PHP Group PHP

1 Answer

How to extract MAC address of vista installed


Here's a piece of VBScript code that performs the function:

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_NetworkAdapter",,48)
For Each objItem in colItems
Wscript.Echo "-----------------------------------"
Wscript.Echo "Win32_NetworkAdapter instance"
Wscript.Echo "-----------------------------------"
Wscript.Echo "MACAddress: " & objItem.MACAddress
Next

You can test this on your machine to see that it works properly. I'm no longer coding with VB6 and don't have the compiler & tools loaded on any of my machines to convert and test there. It should be a simple matter to convert this script to VB6 code.

Jun 27, 2009 | Microsoft Compilers & Programming Tools

2 Answers

Php counter


You might want to note that this is not the most effective manner of creating a counter in PHP. On a few of my websites, I find it is much more effective to simply create a text file, eg. counter.txt and have PHP read that every time the page is loaded, instead of running a MySQL query. Then, have PHP also update the counter.txt file by adding 1 to the number already listed in the file and read to the user.

Mar 19, 2009 | The PHP Group PHP

1 Answer

Php assigning value to variables and posting result, how can i assign a value to variable that will add the score evertytime the answer in my trivia page is correct, how can i make a formula for total...


You can use a session variable.
First use session_start().
Then you can crate a session variable by simply setting the appropriate member of the $_SESSION or $HTTP_SESSION_VARS (PHP < 4.1.0) array
Example.

session_start();

$_SESSION["number"] = 10 ;

echo $_SESSION["number"];

You can call it whenerver you want.
remmember to start session on all the pages where you use the variable.

Mar 17, 2009 | The PHP Group PHP

1 Answer

PHP issues with ''''... Please help!!!


Hello.

If you want PHP to use quotation marks you have to seperate them from the ones that start the expression by a backslash(\).

Here are two examples:
WRONG: echo "A "QUOTE" AND SOME TEXT";
RIGHT: echo "A \"QUOTE\" AND SOME TEXT";

or

WRONG: echo 'A 'QUOTE' AND SOME TEXT';
RIGHT: echo 'A \'QUOTE\' AND SOME TEXT';

I hope this helps.

Kind Regards,
Wilhelm@X-ex.info

Feb 26, 2009 | The PHP Group PHP

1 Answer

Database talks to code but code won't talk to database


Make sure you are connecting to the database,then just before you call your sql to insert use an echo statement to display the sql and check it for syntax:-
$sql = 'insert into table1 values('.$no.','.$no.',"block","'.$value3.'", "'.$value4.'")';
echo "SQL ==>" STARTOFSQL<br>".$sql." ENDOFSQL<br>";

Jan 18, 2009 | The PHP Group PHP

1 Answer

PHP Array Question


<?php
$color = array("red", "blue", "yellow");
foreach($color as $key => $value) {
echo $key . " " . $value . "<br>";
}
?>

More info: http://www.phphelps.com/7_Creating_and_looping_array_in_PHP.shtml

Sep 09, 2008 | The PHP Group PHP

1 Answer

PHP Disappears


To encode a '+' so it will appear as a '+' when decoded
automatically by PHP –
rawurlencode(rawurlencode("+"));

If you just call rawurlencode() once, the resulting "%2B" is converted
to '+' before '+' symbols are converted to spaces, which is not very
useful.

Jul 27, 2008 | The PHP Group PHP

Not finding what you are looking for?
The PHP Group PHP Logo

Related Topics:

1,845 people viewed this question

Ask a Question

Usually answered in minutes!

Top The PHP Group Compilers & Programming Tools Experts

Robin Hill
Robin Hill

Level 3 Expert

1251 Answers

Mike

Level 3 Expert

4331 Answers

Mishan Kasiparsad

Level 2 Expert

142 Answers

Are you a The PHP Group Compiler and Programming Tool Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...