Wonder If PHP Installation Is Complete

Discussion in 'PHP' started by indyjo, Aug 2, 2008.

  1. #1
    Hello everybody,
    I new with PHP but eager to learn. I've just installed PHP5, MySQL5 and Apache2 in my desktop. I have tested them according to the manual and it was okay. I started to get to know with PHP by reading and testing the language by following the php manual. But when it comes to function I found out that it didn't work. Nothing happen in the browser. I gave you one example here:

    <?php
    $money1 = 68.75;
    $money2 = 54.35;
    $money = $money1 + $money2;
    // echo $money will output "123.1";
    $formatted = sprintf("%01.2f", $money);
    // echo $formatted will output "123.10"
    ?>

    Is it because my PHP installation is not complete with function? Anyone here is willing to share knowledge, first of all I would like to say thank you.
     
    indyjo, Aug 2, 2008 IP
  2. jpinheiro

    jpinheiro Peon

    Messages:
    1,211
    Likes Received:
    15
    Best Answers:
    1
    Trophy Points:
    0
    #2
    some functions dont work with the desktop installation try upload to a website sot test thats what i do
     
    jpinheiro, Aug 2, 2008 IP
  3. indyjo

    indyjo Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I'm very sorry. Actually my problem is like this, I mix the PHP with XHTML and the codes is as below:

    <!DOCTYPE html PUBLIC "-//W3C//DTD/XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml11-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <title>A Web Page</title>
    </head>
    <body>

    <p>

    <?php
    $money1 = 68.75;
    $money2 = 54.35;
    $money = $money1 + $money2;
    // echo $money will output "123.1";
    $formatted = sprintf("%01.2f", $money);
    // echo $formatted will output "123.10"
    echo $formatted;
    ?>


    </p>
    </body>
    </html>

    And nothing happend in the browser.
    But when I coded it without XHTML as below:

    <?php
    $money1 = 68.75;
    $money2 = 54.35;
    $money = $money1 + $money2;
    // echo $money will output "123.1";
    $formatted = sprintf("%01.2f", $money);
    // echo $formatted will output "123.10"
    echo $formatted;
    ?>

    The output in the browser is just like that: 123.10

    I wonder why?
     
    indyjo, Aug 2, 2008 IP
  4. Pos1tron

    Pos1tron Peon

    Messages:
    95
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Well my advice is to uninstall and install WAMPServer or something similar - it's all of them, and it's set up for the purpose - much easier to manage, everything'll work, you can install PEAR and such easily...
     
    Pos1tron, Aug 2, 2008 IP
  5. indyjo

    indyjo Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thank you but is it compatible with windows? I'm using windows xp pro sp3.
     
    indyjo, Aug 2, 2008 IP
  6. Pos1tron

    Pos1tron Peon

    Messages:
    95
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #6
    yeah - it's for windows. WAMP stands for Windows Apache Mysql PHP. I personally use WAMPServer (wampserver.com/en/) on my laptop, but I think XAMPP (apachefriends.org/en/xampp.html) is probably the most popular one. You can use multiple versions of php and mysql by downloading a package and installing it, then you can switch between different versions at the click of a button.
     
    Pos1tron, Aug 2, 2008 IP