PHP coder

Discussion in 'General Discussion' started by delta5, Jul 12, 2015.

  1. delta5Well Known MemberMember

    I'll try to explain this

    On my html webpages I want to output text to the body from a php instead of typing it in the html page. Reason being is I want to keep everything clean and run efficiently. I'm also using classes to assign css to each title and another css for the paragraph text.

    On the index page I have:

    I want to replace the text with php code that will display text from another file. Anyone know how?
  2. alinkWell Known MemberMember

    What about something like this

    Then call a Javascript function to get the text and add it to the div value using getelementbyid()? Sorry I'm not great with web code, I'm a .NET guy lol.
  3. delta5Well Known MemberMember

    Maybe use php's f code to open/get/write from a .txt to html? Maybe just leave php alone as much as possible? Without a website/forum my vps is using a little under 200mb of ram. Running centos fully updated with the following installed..

    nano, wget, sudo, and Zpanel that came with LAMP.

    My vps only has 1core, 1gig ram, 50gb ssd, 100mbs link, unlimited bandwidth. If I install mybb my ram usage will prob go up to 700mb?
  4. alinkWell Known MemberMember

    I only took 1 php class and that was about 4 years ago and havent used it since so I'm sure you know a lot more about it than I do lol. From what I remember, I used php on the server to verify data that was sent over a network to make sure that nothing was changed during transmission. I did a little bit of read/write from file but not much, Im not sure how you would read from a file and then return the text from the server to the client with just html code. I think you need an intermediate communicator like Javascript (maybe CSS, im not sure; minor experience with that as well).

    Im not sure what your ram usage is now, or would be with mybb, but 1 gig isnt much for a server. How much traffic do you get?
  5. delta5Well Known MemberMember

    no traffic right now. I just got this vps a few days ago. Also i'm a 100% noob to all of this. It took me an entire day to install centos, update, 'security hardening,' install zpanel, and getting everything to work. I think I had to start over from the very beginning at least 20 times from making mistakes. Traffic is why im rethinking using more php code. mybb will prob eat up a lot of ram. At least my vps plan is easily up-gradable.
  6. ryanrModeratorModerator Member

    Make the page php, not html.
    Create a variable that is your html output.
    At the very end, output the variable to the screen.

    Putting php code in html files won't work because php is server side. The server needs to process first.

    Will try find an example and post
  7. ryanrModeratorModerator Member

    something like this.
    Create a file called index.php
    	$bodytext = '';
    	$divtext = 'hello world';
    	$bodytext .= '<html><body>';
    	$bodytext .= '<div class="p">'.$divtext.'</div>';
    	$bodytext .= '</body></html>';
    	echo $bodytext;
  8. delta5Well Known MemberMember

    Think i'll just stick to html, css, and java script. I'm currently using java script for a button and paypal link. I think i'm spending enough time as it is in GIMP. Site is still looking generic tho lol.

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice