Jump to content

Starting to learn PHP, please help me.


siggibk

Recommended Posts

Okay so i have one question before i start learning php, when you make a function or like date of time, where and how do you make that function appear in a specific division on the site? Do you like make a <div> inside of html for each of the function and then somehow link the function from .php to the html file and then it appears/functions in that section you reffered it in the html file ? 

 

I really hope some of you understand where i'm going with this, sorry for my terrible explanation and my english.

Link to comment
https://forums.phpfreaks.com/topic/285423-starting-to-learn-php-please-help-me/
Share on other sites

It sounds like you should start learning PHP now and ask questions later, rather than ask questions now and learn later. Because the whole idea of learning is so that you don't have to ask questions ;)

 

Short version? You define the function somewhere* and call it at the point you want. Like if the function is

function now() {
    return date("Y-m-d H:i:s");
}
then you can call it as

whatever HTML you want here
<?php

echo now(); // echo to output whatever value now() returned

?>
whatever other HTML you want here
DIVs or SPANs or whatever, it doesn't matter as far as PHP is concerned.

 

* It has to be defined by the time you try to use it. That means you define it in the same file (for the most part), or you define it in another file and require that file (at which point PHP will execute that file and "load" the function).

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.