Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

PHP 

[PHP][HTML][Include only certain line from php file]

Ayo.

Title says it all.


I will have 10k lines so I would have to create 10k php files its very ineficient and slow as I plan to repeat the process later.


Instead I have a bot that will write the 10k lines in one php file.


So question is how do I include it from html but only ONE LINE? not whole php file.

for example in php file i would have:
<?php
echo "first line";
echo "second line";
?>

and i want the html code to return only first line or second (depending which one I choose)

How to? THanks! it took me days to figure it out but no use
That's not how it works. Can't be done. Closest thing is splitting everything up in functions and calling them when they're needed.

Seems like a pretty odd thing to do...
(Jan 1, 2018 05:32 AM)Dialog Wrote:  That's not how it works. Can't be done. Closest thing is splitting everything up in functions and calling them when they're needed.

Seems like a pretty odd thing to do...

but can I call them from html file? I need to display certain line from a file as html. and php include method is the only one I know that could display html code from php file.


http://www.example.com/index.php?option=1
Result: first line
[Image: signaturetwo.png]
(Jan 1, 2018 05:55 AM)Vyxn Wrote:  

http://www.example.com/index.php?option=1
Result: first line


thanks but is there other way to call it than setting url jquery string parameter?
(Jan 1, 2018 06:11 AM)Account of the Gods Wrote:  thanks but is there other way to call it than setting url jquery string parameter?

What are you really want to achieve? Can you tell us so we can point out the right way.
[Image: signaturetwo.png]
(Jan 1, 2018 07:42 AM)Vyxn Wrote:  What are you really want to achieve? Can you tell us so we can point out the right way.

i want normal html code called from external file bro. it should appear on normal html file but without any query strings in the url. and it has to be called from external file.

thats why the include method is nearly perfect.

if its a problem I will just create 10 000 php files with a bot. then include them from html page.

one file will be line1.php
next will be line2.php
line3.php


and each of them will contain different html code (lets say <p>paragraph code</p>)

I am just looking for a easy way to not make 10k files
You need to break up the file then. You are practicing bad coding by trying to do what you are doing.
Only way to achieve this result I guess is in the external HTML file make it connect to a DB and if the assign the slug of the page URL to a particular option as someone suggested 1, 2 or 3.
Then in your 10k of lines, it could be included to then retrieve the page slug that will be dynamic (not using the query string) and then either choose from 1 or 2.
Web Designer / Developer & SEO Expert.

View Work
Earn 10% of the job you refer me to!

Skype aerox.design


Sadly I do not get what you are trying to say, but I picked up bot and a complex php application that involves a lot of lines of code.
When I work with a complex application / bot written in php a seperate my code in chunks in put them in a class so I can easy reuse them and having them in a good order.
Here a 2 file structres from a almost production application:
[Image: njaw2ZBwTsuoFZRWCijv2A.png]
A item system build on PHP for the users of the website split up in classes to organize a huge chunk of code.
[Image: oRIcYFBhT7CpMZl8VMeBsQ.png]
Maybe the most relatable for now, currently a small thing that requires more development but a Teamspeak bot build on PHP to verify ownership of a account.
  • Teamspeak.php - Core Features ( Connection Status, Core Methods, Main Object )

  • /objects - Contains objects I create from the core code or to send to the core code to simplify usage of the application. ( E.G: Create a new TSUser to target a user and execute a task on him )


In order to help you a bit more out you can shoot a PM or send a bit more detailed description maybe with examples. Cause 10K lines of code that need re-usage based of X needs in my opinion rework into OOP.

I hope you have something on this response.
[Image: n4b6KUJ.png]
Can you show a example of a line which is in the file and the exact thing you want the script to do?
(Mar 25, 2018 12:38 PM)SIM-2223238 Wrote:  Can you show a example of a line which is in the file and the exact thing you want the script to do?
Any reason you keep bumping old threads?

I doubt OP is in need of help still.

Je t'aime
[Image: fpZ5a5g.png]

(Apr 22, 2022 04:39 PM)-Scrub Wrote:  Jokes on you, I'm not smart enough to know what he's talking about.
(Mar 25, 2018 12:41 PM)Nachfolger Wrote:  Any reason you keep bumping old threads?

I doubt OP is in need of help still.

Oh didn't check the date, no idea why this was on the first page.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Javascript]  by flexing_99Apr 29, 2023 12:02 AM 3 269 Apr 29, 2023 12:02 AM
Last Post: Zgh600
[Javascript]  by flexing_99Jul 4, 2020 04:11 PM 0 130 Jul 4, 2020 04:11 PM
Last Post: flexing_99
[Javascript]  by AreWeRealApr 6, 2020 02:22 AM 5 209 Apr 6, 2020 02:22 AM
Last Post: AreWeReal