/    Sign up×
Community /Pin to ProfileBookmark

Does The PRE Make Any Difference Here ?

Folks,

Look at these 2 samples. I don;t think the PRE makes any difference but what is best practice ?

[code]
<?php

$x5 = 9; //’Global Variable’ as outside function. It now exists in “Super Global” Variable array as: $GLOBALS[‘x5′].
$y5 = 10; //’Global Variable’ as outside function. It now exists in “Super Global” Variable array as: $GLOBALS[‘y5’].

foreach($GLOBALS as $GLOWBAL)
{
print_r($GLOWBAL);
}

?>
[/code]

[code]
<?php
$x5 = 9; //’Global Variable’ as outside function. It now exists in “Super Global” Variable array as: $GLOBALS[‘x5′].
$y5 = 10; //’Global Variable’ as outside function. It now exists in “Super Global” Variable array as: $GLOBALS[‘y5’].

foreach($GLOBALS as $GLOWBAL)
{
echo “<pre>”;
print_r($GLOWBAL); echo ‘<br>’;
echo “<pre>”;
}

?>
[/code]

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@NogDogApr 06.2021 — &lt;pre&gt; is HTML, not PHP. Use whatever you want for how you want the output to be displayed. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/pre for what that tag does.
Copy linkTweet thisAlerts:
@developer_webauthorApr 06.2021 — @developer_web#1630009

Ah! I just read this now.
Copy linkTweet thisAlerts:
@developer_webauthorApr 06.2021 — @NogDog,

I opened 3 threads with the same code alright but with 3 different questions. Hence, the thread titles have 3 different questions.

You closed this one for nothing:

https://www.webdeveloper.com/d/393541-why-global-variable-shows-undefined-when-using-the-return-function

I haven't got answered yet. So, re-open it. Or, answer that thread's original post here.

I need to know why **return $GLOBALS['z4']** works but not **return $z4**.

You saw all 3 have same code and assumed the questions are the same on all 3 threads. They are not.
Copy linkTweet thisAlerts:
@NogDogApr 06.2021 — See https://www.webdeveloper.com/d/393534-why-global-variable-shows-error-that-variable-undefined where you first bring up this whole globals thing and my couple of replies there. Once you understand the difference between "global scope" and "local scope", along with how "super-global variables" work in either scope, you _might_ start to understand.
Copy linkTweet thisAlerts:
@developer_webauthorApr 08.2021 — @NogDog#1630020

Thanks. Checking it out. I actually missed your reply and the other bloke's there. Reading now.
×

Success!

Help @developer_web spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 3.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,

tipper: Anonymous,
tipped: article
amount: 10 SATS,
)...