Jump to content


Photo

Starting to learn PHP, please help me.


Best Answer requinix, 16 January 2014 - 04:48 PM

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). Go to the full post


  • Please log in to reply
2 replies to this topic

#1 siggibk

siggibk

    Newbie

  • New Members
  • Pip
  • 2 posts

Posted 16 January 2014 - 04:27 PM

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.



#2 requinix

requinix

    Transforming Moderator

  • Moderators
  • 6,306 posts
  • LocationWA

Posted 16 January 2014 - 04:48 PM   Best Answer

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

Edited by requinix, 16 January 2014 - 04:48 PM.


#3 siggibk

siggibk

    Newbie

  • New Members
  • Pip
  • 2 posts

Posted 16 January 2014 - 05:50 PM

Thank you for the answer and yes you are right i should just start learning and ask questions later if i have any, thanks anyway :)






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com