php-lampp-ubuntu: include function doesn't workstartsWith() and endsWith() functions in PHPHow does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?How do I fix Undefined variable error in PHP?Creating a foreach loop to cache html form name in php variablesPHP error: Notice: Undefined offsetcant run my projectActionScripts 3 to PHP email sendProblems with arrays: Notice: Undefined offset: 0sum php multi dimensional array by index value
Is it possible to use .desktop files to open local pdf files on specific pages with a browser?
Do the concepts of IP address and network interface not belong to the same layer?
How do ground effect vehicles perform turns?
Query about absorption line spectra
Could the E-bike drivetrain wear down till needing replacement after 400 km?
What is the grammatical term for “‑ed” words like these?
Why has "pence" been used in this sentence, not "pences"?
Should I install hardwood flooring or cabinets first?
Will adding a BY-SA image to a blog post make the entire post BY-SA?
What does the Rambam mean when he says that the planets have souls?
How much character growth crosses the line into breaking the character
Global amount of publications over time
Engineer refusing to file/disclose patents
How to color a curve
Reply 'no position' while the job posting is still there
Why did the EU agree to delay the Brexit deadline?
Freedom of speech and where it applies
A Permanent Norse Presence in America
Using a siddur to Daven from in a seforim store
Two-sided logarithm inequality
Is XSS in canonical link possible?
Why is Arduino resetting while driving motors?
Greatest common substring
Some numbers are more equivalent than others
php-lampp-ubuntu: include function doesn't work
startsWith() and endsWith() functions in PHPHow does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?How do I fix Undefined variable error in PHP?Creating a foreach loop to cache html form name in php variablesPHP error: Notice: Undefined offsetcant run my projectActionScripts 3 to PHP email sendProblems with arrays: Notice: Undefined offset: 0sum php multi dimensional array by index value
I'm trying to learn include function but it doesn't seem to work, here is my code.
The file count.html.php
:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Counting to ten</title>
</head>
<body>
<p>
<?php echo $output; ?>
</p>
</body>
</html>
And this is my count.php:
<?php
$output = '';
for($count = 1; $count <= 10; $count++)
$output .= $count . ' ';
include './count.html.php';
?>
both are in the same directory
/opt/lampp/htdocs
the error on the browser
Notice: Undefined variable: output in /opt/lampp/htdocs/count.html.php on line 9
php
|
show 11 more comments
I'm trying to learn include function but it doesn't seem to work, here is my code.
The file count.html.php
:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Counting to ten</title>
</head>
<body>
<p>
<?php echo $output; ?>
</p>
</body>
</html>
And this is my count.php:
<?php
$output = '';
for($count = 1; $count <= 10; $count++)
$output .= $count . ' ';
include './count.html.php';
?>
both are in the same directory
/opt/lampp/htdocs
the error on the browser
Notice: Undefined variable: output in /opt/lampp/htdocs/count.html.php on line 9
php
What are errors you are getting?
– RopAli Munshi
Mar 8 at 6:49
Notice: Undefined variable: output in /opt/lampp/htdocs/count.html.php on line 9
– Rabi Laadid
Mar 8 at 6:51
Please show us the contents ofcount.html.php
(the relevant contents , like line 9 and the code related to that line).
– Magnus Eriksson
Mar 8 at 6:58
1
@ChanjungKim - Some developers preferfoo.html.php
when the file also contains HTML and usefoo.php
if the file only contains PHP. That's just a matter of opinion and is off-topic for this issue.
– Magnus Eriksson
Mar 8 at 7:17
1
@ChanjungKim I have changed the extension of the count.html.php to count2.php and also the value of the include to 'count2.php' and they are in the same directory but I'm still getting the same issue
– Rabi Laadid
Mar 8 at 7:23
|
show 11 more comments
I'm trying to learn include function but it doesn't seem to work, here is my code.
The file count.html.php
:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Counting to ten</title>
</head>
<body>
<p>
<?php echo $output; ?>
</p>
</body>
</html>
And this is my count.php:
<?php
$output = '';
for($count = 1; $count <= 10; $count++)
$output .= $count . ' ';
include './count.html.php';
?>
both are in the same directory
/opt/lampp/htdocs
the error on the browser
Notice: Undefined variable: output in /opt/lampp/htdocs/count.html.php on line 9
php
I'm trying to learn include function but it doesn't seem to work, here is my code.
The file count.html.php
:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Counting to ten</title>
</head>
<body>
<p>
<?php echo $output; ?>
</p>
</body>
</html>
And this is my count.php:
<?php
$output = '';
for($count = 1; $count <= 10; $count++)
$output .= $count . ' ';
include './count.html.php';
?>
both are in the same directory
/opt/lampp/htdocs
the error on the browser
Notice: Undefined variable: output in /opt/lampp/htdocs/count.html.php on line 9
php
php
edited Mar 8 at 7:36
Rabi Laadid
asked Mar 8 at 6:48
Rabi LaadidRabi Laadid
14
14
What are errors you are getting?
– RopAli Munshi
Mar 8 at 6:49
Notice: Undefined variable: output in /opt/lampp/htdocs/count.html.php on line 9
– Rabi Laadid
Mar 8 at 6:51
Please show us the contents ofcount.html.php
(the relevant contents , like line 9 and the code related to that line).
– Magnus Eriksson
Mar 8 at 6:58
1
@ChanjungKim - Some developers preferfoo.html.php
when the file also contains HTML and usefoo.php
if the file only contains PHP. That's just a matter of opinion and is off-topic for this issue.
– Magnus Eriksson
Mar 8 at 7:17
1
@ChanjungKim I have changed the extension of the count.html.php to count2.php and also the value of the include to 'count2.php' and they are in the same directory but I'm still getting the same issue
– Rabi Laadid
Mar 8 at 7:23
|
show 11 more comments
What are errors you are getting?
– RopAli Munshi
Mar 8 at 6:49
Notice: Undefined variable: output in /opt/lampp/htdocs/count.html.php on line 9
– Rabi Laadid
Mar 8 at 6:51
Please show us the contents ofcount.html.php
(the relevant contents , like line 9 and the code related to that line).
– Magnus Eriksson
Mar 8 at 6:58
1
@ChanjungKim - Some developers preferfoo.html.php
when the file also contains HTML and usefoo.php
if the file only contains PHP. That's just a matter of opinion and is off-topic for this issue.
– Magnus Eriksson
Mar 8 at 7:17
1
@ChanjungKim I have changed the extension of the count.html.php to count2.php and also the value of the include to 'count2.php' and they are in the same directory but I'm still getting the same issue
– Rabi Laadid
Mar 8 at 7:23
What are errors you are getting?
– RopAli Munshi
Mar 8 at 6:49
What are errors you are getting?
– RopAli Munshi
Mar 8 at 6:49
Notice: Undefined variable: output in /opt/lampp/htdocs/count.html.php on line 9
– Rabi Laadid
Mar 8 at 6:51
Notice: Undefined variable: output in /opt/lampp/htdocs/count.html.php on line 9
– Rabi Laadid
Mar 8 at 6:51
Please show us the contents of
count.html.php
(the relevant contents , like line 9 and the code related to that line).– Magnus Eriksson
Mar 8 at 6:58
Please show us the contents of
count.html.php
(the relevant contents , like line 9 and the code related to that line).– Magnus Eriksson
Mar 8 at 6:58
1
1
@ChanjungKim - Some developers prefer
foo.html.php
when the file also contains HTML and use foo.php
if the file only contains PHP. That's just a matter of opinion and is off-topic for this issue.– Magnus Eriksson
Mar 8 at 7:17
@ChanjungKim - Some developers prefer
foo.html.php
when the file also contains HTML and use foo.php
if the file only contains PHP. That's just a matter of opinion and is off-topic for this issue.– Magnus Eriksson
Mar 8 at 7:17
1
1
@ChanjungKim I have changed the extension of the count.html.php to count2.php and also the value of the include to 'count2.php' and they are in the same directory but I'm still getting the same issue
– Rabi Laadid
Mar 8 at 7:23
@ChanjungKim I have changed the extension of the count.html.php to count2.php and also the value of the include to 'count2.php' and they are in the same directory but I'm still getting the same issue
– Rabi Laadid
Mar 8 at 7:23
|
show 11 more comments
1 Answer
1
active
oldest
votes
If you read your error message carefully, it points you at the line 9 of the file count.html.php (obviously because you have less than 9 lines in count.php).
That means either that
- the code you show us is not the actual code you test... then we really cannot help
- you access the wrong file
It is just impossible that the include fails, as you think, you have to rethink that hypothesis
If you get this error accessing count.php that means the include worked because the error points at the line 9 of a file that have less than 9 lines, so it points at the line 9 of the included file.
Most likely your are trying to access the file count.html.php directly from your browser, when you actually meant to access the other file count.php, the one that defines the variable $output
That's exaclty what I'm trying to do, but the function "include" doesn't seem to work
– Rabi Laadid
Mar 8 at 7:35
No. There is no line 9 on the pure PHP file (cf your error) that means that you are accessing the wrong file
– b.enoit.be
Mar 8 at 7:36
it refers to the line in the first file count.html.php where it declares the variable output, the only problem that varial get its definition from count.php. sorry if I can't clarify my problem properly, I'm still new to php
– Rabi Laadid
Mar 8 at 7:45
Read the answer again and rethink your hypothesis. If you stick yourself to the ”the include do not work“ one, you are loosing your time and won’t find your issue nor will you be able to explain it for us to help you
– b.enoit.be
Mar 8 at 7:52
Thank you so much now I get it, I was trying to access count.php from the html file since I thougth html is the file meant to deal with the browser.
– Rabi Laadid
Mar 8 at 7:56
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55058080%2fphp-lampp-ubuntu-include-function-doesnt-work%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you read your error message carefully, it points you at the line 9 of the file count.html.php (obviously because you have less than 9 lines in count.php).
That means either that
- the code you show us is not the actual code you test... then we really cannot help
- you access the wrong file
It is just impossible that the include fails, as you think, you have to rethink that hypothesis
If you get this error accessing count.php that means the include worked because the error points at the line 9 of a file that have less than 9 lines, so it points at the line 9 of the included file.
Most likely your are trying to access the file count.html.php directly from your browser, when you actually meant to access the other file count.php, the one that defines the variable $output
That's exaclty what I'm trying to do, but the function "include" doesn't seem to work
– Rabi Laadid
Mar 8 at 7:35
No. There is no line 9 on the pure PHP file (cf your error) that means that you are accessing the wrong file
– b.enoit.be
Mar 8 at 7:36
it refers to the line in the first file count.html.php where it declares the variable output, the only problem that varial get its definition from count.php. sorry if I can't clarify my problem properly, I'm still new to php
– Rabi Laadid
Mar 8 at 7:45
Read the answer again and rethink your hypothesis. If you stick yourself to the ”the include do not work“ one, you are loosing your time and won’t find your issue nor will you be able to explain it for us to help you
– b.enoit.be
Mar 8 at 7:52
Thank you so much now I get it, I was trying to access count.php from the html file since I thougth html is the file meant to deal with the browser.
– Rabi Laadid
Mar 8 at 7:56
add a comment |
If you read your error message carefully, it points you at the line 9 of the file count.html.php (obviously because you have less than 9 lines in count.php).
That means either that
- the code you show us is not the actual code you test... then we really cannot help
- you access the wrong file
It is just impossible that the include fails, as you think, you have to rethink that hypothesis
If you get this error accessing count.php that means the include worked because the error points at the line 9 of a file that have less than 9 lines, so it points at the line 9 of the included file.
Most likely your are trying to access the file count.html.php directly from your browser, when you actually meant to access the other file count.php, the one that defines the variable $output
That's exaclty what I'm trying to do, but the function "include" doesn't seem to work
– Rabi Laadid
Mar 8 at 7:35
No. There is no line 9 on the pure PHP file (cf your error) that means that you are accessing the wrong file
– b.enoit.be
Mar 8 at 7:36
it refers to the line in the first file count.html.php where it declares the variable output, the only problem that varial get its definition from count.php. sorry if I can't clarify my problem properly, I'm still new to php
– Rabi Laadid
Mar 8 at 7:45
Read the answer again and rethink your hypothesis. If you stick yourself to the ”the include do not work“ one, you are loosing your time and won’t find your issue nor will you be able to explain it for us to help you
– b.enoit.be
Mar 8 at 7:52
Thank you so much now I get it, I was trying to access count.php from the html file since I thougth html is the file meant to deal with the browser.
– Rabi Laadid
Mar 8 at 7:56
add a comment |
If you read your error message carefully, it points you at the line 9 of the file count.html.php (obviously because you have less than 9 lines in count.php).
That means either that
- the code you show us is not the actual code you test... then we really cannot help
- you access the wrong file
It is just impossible that the include fails, as you think, you have to rethink that hypothesis
If you get this error accessing count.php that means the include worked because the error points at the line 9 of a file that have less than 9 lines, so it points at the line 9 of the included file.
Most likely your are trying to access the file count.html.php directly from your browser, when you actually meant to access the other file count.php, the one that defines the variable $output
If you read your error message carefully, it points you at the line 9 of the file count.html.php (obviously because you have less than 9 lines in count.php).
That means either that
- the code you show us is not the actual code you test... then we really cannot help
- you access the wrong file
It is just impossible that the include fails, as you think, you have to rethink that hypothesis
If you get this error accessing count.php that means the include worked because the error points at the line 9 of a file that have less than 9 lines, so it points at the line 9 of the included file.
Most likely your are trying to access the file count.html.php directly from your browser, when you actually meant to access the other file count.php, the one that defines the variable $output
edited Mar 9 at 21:44
answered Mar 8 at 7:30
b.enoit.beb.enoit.be
5,14842842
5,14842842
That's exaclty what I'm trying to do, but the function "include" doesn't seem to work
– Rabi Laadid
Mar 8 at 7:35
No. There is no line 9 on the pure PHP file (cf your error) that means that you are accessing the wrong file
– b.enoit.be
Mar 8 at 7:36
it refers to the line in the first file count.html.php where it declares the variable output, the only problem that varial get its definition from count.php. sorry if I can't clarify my problem properly, I'm still new to php
– Rabi Laadid
Mar 8 at 7:45
Read the answer again and rethink your hypothesis. If you stick yourself to the ”the include do not work“ one, you are loosing your time and won’t find your issue nor will you be able to explain it for us to help you
– b.enoit.be
Mar 8 at 7:52
Thank you so much now I get it, I was trying to access count.php from the html file since I thougth html is the file meant to deal with the browser.
– Rabi Laadid
Mar 8 at 7:56
add a comment |
That's exaclty what I'm trying to do, but the function "include" doesn't seem to work
– Rabi Laadid
Mar 8 at 7:35
No. There is no line 9 on the pure PHP file (cf your error) that means that you are accessing the wrong file
– b.enoit.be
Mar 8 at 7:36
it refers to the line in the first file count.html.php where it declares the variable output, the only problem that varial get its definition from count.php. sorry if I can't clarify my problem properly, I'm still new to php
– Rabi Laadid
Mar 8 at 7:45
Read the answer again and rethink your hypothesis. If you stick yourself to the ”the include do not work“ one, you are loosing your time and won’t find your issue nor will you be able to explain it for us to help you
– b.enoit.be
Mar 8 at 7:52
Thank you so much now I get it, I was trying to access count.php from the html file since I thougth html is the file meant to deal with the browser.
– Rabi Laadid
Mar 8 at 7:56
That's exaclty what I'm trying to do, but the function "include" doesn't seem to work
– Rabi Laadid
Mar 8 at 7:35
That's exaclty what I'm trying to do, but the function "include" doesn't seem to work
– Rabi Laadid
Mar 8 at 7:35
No. There is no line 9 on the pure PHP file (cf your error) that means that you are accessing the wrong file
– b.enoit.be
Mar 8 at 7:36
No. There is no line 9 on the pure PHP file (cf your error) that means that you are accessing the wrong file
– b.enoit.be
Mar 8 at 7:36
it refers to the line in the first file count.html.php where it declares the variable output, the only problem that varial get its definition from count.php. sorry if I can't clarify my problem properly, I'm still new to php
– Rabi Laadid
Mar 8 at 7:45
it refers to the line in the first file count.html.php where it declares the variable output, the only problem that varial get its definition from count.php. sorry if I can't clarify my problem properly, I'm still new to php
– Rabi Laadid
Mar 8 at 7:45
Read the answer again and rethink your hypothesis. If you stick yourself to the ”the include do not work“ one, you are loosing your time and won’t find your issue nor will you be able to explain it for us to help you
– b.enoit.be
Mar 8 at 7:52
Read the answer again and rethink your hypothesis. If you stick yourself to the ”the include do not work“ one, you are loosing your time and won’t find your issue nor will you be able to explain it for us to help you
– b.enoit.be
Mar 8 at 7:52
Thank you so much now I get it, I was trying to access count.php from the html file since I thougth html is the file meant to deal with the browser.
– Rabi Laadid
Mar 8 at 7:56
Thank you so much now I get it, I was trying to access count.php from the html file since I thougth html is the file meant to deal with the browser.
– Rabi Laadid
Mar 8 at 7:56
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55058080%2fphp-lampp-ubuntu-include-function-doesnt-work%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What are errors you are getting?
– RopAli Munshi
Mar 8 at 6:49
Notice: Undefined variable: output in /opt/lampp/htdocs/count.html.php on line 9
– Rabi Laadid
Mar 8 at 6:51
Please show us the contents of
count.html.php
(the relevant contents , like line 9 and the code related to that line).– Magnus Eriksson
Mar 8 at 6:58
1
@ChanjungKim - Some developers prefer
foo.html.php
when the file also contains HTML and usefoo.php
if the file only contains PHP. That's just a matter of opinion and is off-topic for this issue.– Magnus Eriksson
Mar 8 at 7:17
1
@ChanjungKim I have changed the extension of the count.html.php to count2.php and also the value of the include to 'count2.php' and they are in the same directory but I'm still getting the same issue
– Rabi Laadid
Mar 8 at 7:23