#1

  1. Join Date
    Sep 2013
    Location
    Lahore, Pakistan
    Posts
    74
    Rep Power
    1

    Post Please teach me basics


    Hi sir;

    I am newbie in php,
    learning it.

    and writing my php blog daily

    I am getting problem in printf() function.

    how to use it? i saw in many forums and groups, 75% people are getting problem for printf() function.

    can anyone guide me properly.

    I checked w3 but there syntax is :

    printf(format,arg1,arg2,arg++)

    I am little bit confuse.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Location
    /root
    Posts
    14
    Rep Power
    0
    What you probably are looking for, is codeacademy. Google it, it has some great tutorials and live demonstrations. It teaches you from the floor up to the good stuff. ^^
  4. #3
  5. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Hi,

    don't use w3schools. They're infamous for wrong and outdated information, insecure code, bad practices and plain nonsense. Despite their name, they're not associated with the W3C in any way. It's a private company trying to sell useless certificates. And obviously they're very good at fooling newbies and getting on top of every search result.

    If you want technical information about PHP, go to the official manual. Just type the name of the function into the search field on top, and you'll get an extensive description and practical examples.

    Try it with printf(). They'll point you to sprintf() for more information. At the bottom, there are plenty of examples. That should give you a pretty good idea of how the function works even if you don't understand every detail.

    In a nutshell, printf() is for outputting formatted data (hence the name). The first argument is a template string with special markers telling PHP how to format the data and where to insert it. And the other arguments are for the actual data.

    A classical example would be number formatting: Let's say you have different numbers, and you always want to display them with two decimal places. printf() let's you do that easily:

    PHP Code:
    <?php

    $price 
    5;        // this is an integer, but we want to display it as 5.00

    printf('The price is $%.2f'$price);
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  6. #4

  7. Join Date
    Sep 2013
    Location
    Lahore, Pakistan
    Posts
    74
    Rep Power
    1

    Post good site.


    Originally Posted by IngwiePhoenix
    codeacademy. Google it
    It did and I try to brows it deeply ; let's see what i learn.
  8. #5

  9. Join Date
    Sep 2013
    Location
    Lahore, Pakistan
    Posts
    74
    Rep Power
    1

    nice sir


    Originally Posted by Jacques1
    don't use w3schools. They're infamous for wrong and outdated information, insecure code, bad practices and plain nonsense. Despite their name, they're not associated with the W3C in any way. It's a private company trying to sell useless certificates. And obviously they're very good at fooling newbies and getting on top of every search result.
    I checked personally , there are many things outdated.

    if you talk about to
    getting on top of every search result.
    then you are right it is a SEO back age method. Make more than more pages, every page should be indexed; you will get rank easily. and if you have rank. then you can get traffic and adsense clicks, etc.

    I'll tell it to my friends. why do they make it famous?

    I checked php.net but there is a lot of stuff? I saw and say WOW. hehehhehhe

    I am newbie so don't want to take too much confusions. that's why I post thread here.

    when i'll have some good knowledge i'll check that daily.

    great; sir i learned it easily. yes; now.

    but your code has error you did not close it. ; error is error.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Location
    /root
    Posts
    14
    Rep Power
    0
    Originally Posted by same2cool
    but your code has error you did not close it. ; error is error.
    Just one thing. PHP code doesnt need to be "closed."

    PHP Code:
    <?php
    echo "foo\n";
    echo 
    "bar\n";
    That will work, as long as you dont need to implement some HTML into the same script. But if you learn about MVC, you will realize, that in these situations you wont need a closing tag anyway
  12. #7

  13. Join Date
    Sep 2013
    Location
    Lahore, Pakistan
    Posts
    74
    Rep Power
    1

    Wink opppssss


    Originally Posted by IngwiePhoenix
    Just one thing. PHP code doesnt need to be "closed."
    I upgrade my knowledge here. and say Oppppssss.

    What is MVC? You used it.
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Location
    /root
    Posts
    14
    Rep Power
    0
    Originally Posted by same2cool
    I upgrade my knowledge here. and say Oppppssss.

    What is MVC? You used it.
    MVC : Model View Controller

    It basically is what deives allmost ALL websites - its a concept of seperating the view from the data.

    For example, I use a framework called Yii. In this framework, you have files like SiteController.php - and a folder called views with a subfolder called site. You maybe just noticed that the folder site nearly matches the name SiteController.

    In this moment, one could tell this is MVC. The SiteController establishes a connection to a Database, for example, and then passes the data into the view. It is a concept you may want to learn once you get yourself started and more confortable with PHP.

    But if you are curios nonthless, take your time and google this: mvc php

    You maybe even end up at the yii page x3
  16. #9

  17. Join Date
    Sep 2013
    Location
    Lahore, Pakistan
    Posts
    74
    Rep Power
    1
    Originally Posted by IngwiePhoenix
    MVC : Model View Controller
    thanks for information dear
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,989
    Rep Power
    375
    come on man, not to sound harsh, you shouldnt take this board for granted and post EVERY SINGLE problem you are having! use your common sense and google first. for example if someone mentioned MVC, if you googled it you would have got explanation AND examples

    Comments on this post

    • Jacques1 agrees
  20. #11

  21. Join Date
    Sep 2013
    Location
    Lahore, Pakistan
    Posts
    74
    Rep Power
    1

    Thumbs up


    Originally Posted by paulh1983
    come on man, not to sound harsh, you shouldnt take this board for granted and post EVERY SINGLE problem you are having! use your common sense and google first. for example if someone mentioned MVC, if you googled it you would have got explanation AND examples
    Now i'll remind it Sir.

IMN logo majestic logo threadwatch logo seochat tools logo