Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Closed Thread
 
Thread Tools Display Modes
Share |
  #1  
Old 12-16-2016, 03:30 AM
iwebguy iwebguy is offline
Banned
 
Join Date: 11-27-16
Posts: 30
iTrader: 0 / 0%
What will be the output of the following PHP code ?

PHP Code:
<?php

    $x
;

    echo 
"$x";

    
?>
 

Advertisement

Advertisement

  #2  
Old 12-16-2016, 04:11 AM
ScriptMan's Avatar
ScriptMan ScriptMan is online now
Super Moderator
 
Join Date: 02-10-07
Location: Central Kentucky
Posts: 14,023
iTrader: 4 / 100%
A blank page.

Questions?
 
  #3  
Old 12-16-2016, 11:11 AM
afam4eva afam4eva is offline
Contributing Member
 
Join Date: 11-09-09
Posts: 72
iTrader: 0 / 0%
It will display a blank page because you did not attribute a value to $x.

If you had done this
PHP Code:
<?php
$x
=20;

echo 
$x;
?>
Then 20 will display.
 
  #4  
Old 12-17-2016, 11:05 AM
gxnpt's Avatar
gxnpt gxnpt is offline
Contributing Member
 
Join Date: 09-10-16
Location: far west Florida near Destin
Posts: 104
iTrader: 0 / 0%
the echo "$x" (double quotes) will give the same result as echo $x (no quotes)

( the value of $x )

echo '$x' will give the text inside the single quotes

PHP Code:
$x=20;
echo 
$x;
echo 
"<br>***<br>$x<br>***<br>";
echo 
'$x'
gives

20
***
20
***
$x
 
  #5  
Old 12-19-2016, 07:28 AM
jenniferrainey jenniferrainey is offline
Junior Member
 
Join Date: 12-15-16
Posts: 7
iTrader: 0 / 0%
It will through a PHP Notice.
Notice: Undefined variable: x

you have to assign a value to $x or set it null.
$x = null;
$x = 20;
 
  #6  
Old 12-19-2016, 07:43 AM
gxnpt's Avatar
gxnpt gxnpt is offline
Contributing Member
 
Join Date: 09-10-16
Location: far west Florida near Destin
Posts: 104
iTrader: 0 / 0%
correct re the notice - unless error reporting is suppressed already as in error_reporting(0);

PHP Code:
error_reporting(0);
//$x=20;
echo $x;
echo 
"<br>***<br>$x<br>***<br>";
echo 
'$x'
results in

Quote:

***

***
$x
instead of
Quote:

Notice: Undefined variable: x in C:\xampp\htdocs\test.php on line 3

Notice: Undefined variable: x in C:\xampp\htdocs\test.php on line 4

***

***
$x

Last edited by gxnpt; 12-19-2016 at 07:47 AM.
 
Go Back   Webmaster Forum > Web Development > Coding Forum

Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
print_r() output klwm Coding Forum 4 12-20-2013 01:40 PM
How can i get H.264 output in after effects? dtommy79 Graphic Design Forum 4 02-10-2013 11:54 AM
NMS Mail, Formatting output, etc. hotwired99 Coding Forum 0 08-30-2012 02:08 AM
Need some help with php output Newbe Coding Forum 3 09-05-2008 08:44 AM
Why does this not output? thenextbesthang Coding Forum 3 12-29-2006 12:31 PM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 06:43 AM.
Powered by vBulletin
Copyright 2000-2014 Jelsoft Enterprises Limited.
Copyright © 2003 - 2018 VIX-WomensForum LLC