Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Nov 2011
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Help with PHP code

    I am new to php and need help getting a program started. I need to figure a php code of a table of squares: The square of 1 is 1
    The square of 2 is 4
    The square of 3 is 9

    Could someone help me get on track?

    Thanks,
    Cat

  • #2
    Regular Coder
    Join Date
    Jul 2010
    Location
    Oregon City
    Posts
    280
    Thanks
    5
    Thanked 50 Times in 49 Posts
    Quote Originally Posted by catgillespie View Post
    I am new to php and need help getting a program started. I need to figure a php code of a table of squares: The square of 1 is 1
    The square of 2 is 4
    The square of 3 is 9

    Could someone help me get on track?

    Thanks,
    Cat

    PHP Code:
    function sq($num)
    {
    return 
    $num^2;

    or just

    PHP Code:

    for($i=0;$i<50;$i++)
    {
    echo 
    "The square of $i is ". ($i^2) . "<br />";


  • Users who have thanked Adee for this post:

    catgillespie (11-19-2011)

  • #3
    New to the CF scene
    Join Date
    Nov 2011
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I could not get this to work....


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •