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 gram­mat­i­cal 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













-1















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











share|improve this question
























  • 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 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





    @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















-1















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











share|improve this question
























  • 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 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





    @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













-1












-1








-1








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











share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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 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





    @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











  • 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 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





    @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












1 Answer
1






active

oldest

votes


















0














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






share|improve this answer

























  • 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










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
);



);













draft saved

draft discarded


















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









0














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






share|improve this answer

























  • 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















0














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






share|improve this answer

























  • 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













0












0








0







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






share|improve this answer















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







share|improve this answer














share|improve this answer



share|improve this answer








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

















  • 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



















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page