1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Beginners Guide for PHP

Discussion in 'PHP' started by roopajyothi, Apr 25, 2010.

  1. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    SEMrush
  2. mehmetm

    mehmetm Well-Known Member

    Messages:
    134
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    110
    #22
    I see you live with PHP huh ? :)
    thanks for your all posts and sharing information with us..
     
    mehmetm, Jun 6, 2010 IP
  3. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #23
    OMG!
    I am in Vacation In India and applied for US Visa from Canadian Visa

    It's boring!
    Things go here so slowly!
    So only i scraping the things i know about PHP!
    BTW: I am not even a Computer Engineer First! I am just posting what i know!
     
    roopajyothi, Jun 8, 2010 IP
  4. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #24
    Today's a PHP Tip [Core]:

    In PHP Whatever you assigning in right side of a variable ( after that equal to i.e =) is evaluated First!
    Then it will be stored in left Side Variable! :)
     
    roopajyothi, Jun 8, 2010 IP
  5. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #25
    roopajyothi, Jun 12, 2010 IP
  6. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #26
    roopajyothi, Jun 17, 2010 IP
  7. iimmdeepak

    iimmdeepak Peon

    Messages:
    208
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #27
    Thanks roop for so much info on PHP well i m a begginer and i want to know is php good or asp.
    Thanks for the reply in advance.
     
    iimmdeepak, Jun 18, 2010 IP
  8. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #28
    Well!
    Read the first post there are plenty of resources that links too :)
     
    roopajyothi, Jun 18, 2010 IP
  9. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #29
    PRINT Vs ECHO

    1. Echo works faster than print().
    2. Echo and print are language construct.
    3. Print behaves as a function and it returns an integer value.
    4. Echo does not returns any values.
    5. Echo is not suitable for conditional construct
    6. Print is suitable for conditional construct.
    7. Print process is slower than echo .

    Credits: forum_scripteen
     
    roopajyothi, Jun 18, 2010 IP
  10. ZeeshanButt

    ZeeshanButt Active Member

    Messages:
    306
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #30
    If anyone has any small php issue, ask me. I will do it free of cost for you.
     
    ZeeshanButt, Jun 18, 2010 IP
  11. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #31
    Introduction

    This article is for people who are not aware what PHP is or who have not heard of PHP. This article will inform you about what PHP is with some of the important highlights .



    PHP!!! PHP!!!! PHP!!!! What is it????

    Don't worry; I am here to tell you, what it is?
    Hi Net mates. These days, when you surf through some sites, you will find some file extension in the address bar of your browser. For example: .htm, .asp, .jsp, .php, .php3 You will find the extension: .php or the. Php3 file extension in some of the popular sites too. Let us see what this file extension is, which language this extension refers to, and what are the main highlights of this language.
    Hyper text pre processor is the exact expansion of PHP, tough it doesn't, fit to the exact spelling. It is adjusted to the word of mouth, called PHP. PHP is a web scripting language. Let us see some the basic queries, which we come across in PHP.



    Who wrote PHP?

    Rasmus wrote PHP. PHP was started off accidentally, Rasmus was designing his web site, and he had planed to put a hit counter for his site. He decided to write a combination of Perl. There were many enquires about the script which he used. Likewise it slowly improved on, and won the hearts of many programmers.



    What type of scripting is PHP client or a server side?

    PHP is a server-side scripting language. A server-side scripting language is one, which has the capability of executing the script on the server and serving the output as an HTML file. Server-side scripts have the main advantage of interacting with databases, as well as performing all types of server manipulations directly. Server-side scripting languages can manipulate the data which is received from web forms, anywhere on the Net.
    But this is not the case with client-side scripts such as JavaScript and VBScript. However, there are exceptions where, client-side scripts can also be used for server-side scripting, but this is limited to some extent.



    Can I use PHP with HTML?

    Sure, you can very well use HTML with PHP. Like the other scripting languages you can do so but it is not a compulsory act for you to use PHP with HTML. You can very well get the output with PHP alone. But the expected out put which is exhibited by PHP is not that attractive for display, attractive meaning the formatting which is done by PHP.
    Let us take an example: You have a server-side interaction with the database which is used to manipulate and fetch a certain type of data based on the query which is given out, now if you are going to display this data using PHP, the quality of the output, regarding such criteria as: font-face, font coloring and display areas all are disturbed, and painful to locate and place the data. If HTML is used to present this data, the outlook of the data exhibited can be gorgeous.



    Can I Run PHP on Windows Operating System?

    You can very well run PHP on Windows machines. PHP is a cross-platform support language, which means, PHP can run on various platforms such as Linux, Windows etc. Web servers such as PWS, IIS and Apache can be configured to work with PHP.



    Is it easy migrating from any other server side scripting languages to PHP?

    If you are aware of programming concepts and the application of the logic, then, you will find it relatively easy to code any programming language by understanding the syntax. PHP's functions are similar to other scripting languages. The only thing that matters is your requirement, how you are going to apply the logic and code php to your logic.
    The main consideration when migrating from a different language lies with the syntax. PHP syntax is similar to that of the C language. People with a basic understanding of C will find it very easy to migrate to PHP.



    I am new to programming, is it easy to learn PHP?

    If you are blind to programming then it may be difficult to learn PHP, as you will need to learn the programming concepts, understand the logic and troubleshoot the programs. If you happen to know at least one programming language, then it is very easy to learn PHP. PHP it is pretty easy compared to other scripting languages.



    What are the databases that support PHP?

    PHP is very much compatible with MYSQL and POSTGRESQL Databases. PHP also can be programmed to interact with any database right from a simple text file to DB2. It is believed that PHP's ability to interact with databases is greater than any other scripting languages.



    How fast is PHP compared with other scripting languages?

    PHP is believed to be fast when compared with other programming languages, Because of execution speed. In the case of large interactions with the database, PHP really plays a good role of execution in performing the interaction. Now a days major web sites have been migrating to PHP, because of the performance.



    PHP is open source; will this work properly?

    PHP is the only scripting language, which has won the hearts of many web servers and has been moving on enormously day-by-day, The main advantages of open source software is that, if there is a problem, that particular problem is shared my millions of programmers across the world. But in the case of licensed version scripting languages, it is very limited to a set of a small community.
    Because innovative ideas are studied by many programmers across the world, new ideas are implemented then and there, making the language strong. There is no problem in using PHP, which is open source.
    I shall conclude by saying that, all the scripting languages have their own merits and demerits, it is up to you to decide whether to go for a partial migration or a full migration



    What are the main advantages of PHP?

    PHP has many advantages over other scripting languages. Some of the important highlights are as follows:
    Speed - PHP is considered to be the fastest of the scripting languages. You can really feel the speed when you implement scripts live on the web. Normally when you try to connect a database and fetch certain data, it takes time to connect the database, execute the statement and get the data across.
    Because of its high performance in terms of speed, PHP is being used for some of the important Web server administration such as mail functionality.
    Open Source - PHP is open source. This means users are given a free license to remodel or recode PHP, according to their wishes. You might wonder how this is possible without source code but source code is shipped with PHP - it is open source.
    Multi Platform - PHP supports various Plat forms, which means PHP can be installed on almost all operating systems such as Windows-x and Linux, just choose the appropriate version to download and follow the instructions given in the Manual accordingly.
    Easy Syntax - PHP syntax is quite easy to code. It is similar to that of the C language. If you are new to the programming environment however, getting used to the syntax may be a bit difficult.



    What are the main disadvantages of PHP?

    Every language/scripting language has its own advantages and disadvantages and PHP also has some disadvantages. Some are direct disadvantages and some are indirect regarding functionality.
    Error Handling - When it comes to error handling, it is believed that PHP has a very poor ability but even this disadvantage can be over come using a feasible advantage solution.
    It is up to you to decide, whether to migrate or learn PHP.
    PHP is great in the terms of performance of speed, which is the main factor, which people expect these days.

    Source
     
    roopajyothi, Jun 20, 2010 IP
  12. clox.c

    clox.c Peon

    Messages:
    30
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #32
    great work!
    helpful in many ways
     
    clox.c, Jun 20, 2010 IP
  13. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #33
    Well thanks will soon write and show you sample codes :)
     
    roopajyothi, Jul 1, 2010 IP
  14. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #34
    Why "micro-"? Because changing logic of your application may give you much better performance boost then applying all these tips. But they still can make your code better. You always need to output something, why do not use "echo" instead of "print"?

    * calling an object method is faster then traping it with with "__call"

    * calling a "static" method is faster then an object method

    * calling a function is faster then calling a static method

    * accessing a local variable is faster then then a global variable

    * accessing a global variable is faster then an object property

    * accessing an object property is faster then trapping it with "__get" and "__set"

    * accessing an initialized variable is faster then accessing an uninitialized variable

    * absolute paths in "include" and "require" are faster then relative

    * merging several scripts in one file and then including it is faster then several includes

    * "switch" is faster then "if ... else if ..." in some cases

    * do not use regexs for simple string processing tasks

    * avoid @ (error control operator)

    * avoid notices and warnings in your scripts

    * avoid unused variables and unused method parameters

    * adding method parameter increases calling time

    * adding method parameter type hint increases calling time

    * unset variables that contain large amount of data or circular references

    * $_SERVER['REQUEST_TIME'] contains script startup time

    * cache page output or result of resource-consuming functions

    * "echo" is faster than "print"

    * "echo" accepts several arguments, you can use it instead of string concatenation

    * "ob_start()" and "ob_end_clean()" is may be better then several string concatenations

    * strings in single quotes ('...') are processed faster then strings in double quotes ("...")

    * pre-increment (++$i) is faster then post-increment ($i++)

    * "isset" is a faster alternative to "array_key_exists"

    * an array is a faster alternative to a class with several fields

    * "foreach" is better then "for" in many cases

    * open resources (files, database connections, sockets) right before using them, free resources as soon as you do not need them

    * do not fetch database fields which you do not use in your script

    * use prepared database statements

    * combine several queries in one when database supports it


    Source: Alex@Net
     
    roopajyothi, Jul 1, 2010 IP
  15. strgraphics

    strgraphics Active Member

    Messages:
    711
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #35
    superb...........!
     
    strgraphics, Jul 1, 2010 IP
  16. fluteofliar

    fluteofliar Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #36
    please put some information about memory mangement in php, i mena how static,global,superglobal avriable allocated and where they are
    allocated in memory
     
    fluteofliar, Jul 2, 2010 IP
  17. lukeg32

    lukeg32 Peon

    Messages:
    645
    Likes Received:
    19
    Best Answers:
    1
    Trophy Points:
    0
    #37
    Oh dear,

    Those above are incorrect. print is faster than echo... and it does NOT return an integer value (it returns 1.....)

    http://www.im-wizard.com/wp-content/uploads/2010/07/print1.jpg
     
    lukeg32, Jul 2, 2010 IP
  18. lcwadminbj

    lcwadminbj Peon

    Messages:
    402
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #38
    Although technically correct as far as it goes you failed to close the paragraph.
    using your method that wouold be
    echo"</p>"; placed before the ?></body>

    however there is an alternative and (in my opinion) simpler way to write the same thing.

    <HTML><BODY>
    <? echo date("M-d-Y") . "<P>
    Your IP Address is " . $_SERVER['REMOTE_ADDR'] . "</p>";
    ?>
    </BODY></HTML>

    Doing this you reduce the footprint (size) of the code by eliminating three echo commands.
    a smaller footprint means faster loading to the visitors browser.

    Although with this one example it would make no noticable difference
    The difference would be noticable on a complete page where coding
    optimization has been done and the excesive and unnecessary coding has been removed.

    In My Opinion it is easier to start out using optimized code rather than to try and learn to convert to optimized coding after learing the long version.
     
    Last edited: Jul 2, 2010
    lcwadminbj, Jul 2, 2010 IP
  19. lukeg32

    lukeg32 Peon

    Messages:
    645
    Likes Received:
    19
    Best Answers:
    1
    Trophy Points:
    0
    #39
    You talk about optimized code, and yet concatenating (with echo) is one of the slowest ways to do it. If you must use echo, at the very least use comma seperators NOT concatenate.
     
    lukeg32, Jul 2, 2010 IP
  20. Wamer

    Wamer Greenhorn

    Messages:
    73
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #40
    Nice basics tutorial :)
     
    Wamer, Jul 2, 2010 IP