Announcement

Collapse
No announcement yet.

Why so many built-in functions for PHP?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Why so many built-in functions for PHP?

    Why are there so many built-in functions for PHP?

    Are half of them even useful? At all? I'm learning from a book I just got called "PHP/MySQL web development" and I'm in chapter 3: arrays and out of 15 pages or so that I've read so far I've been introduced to about 10 functions!!!
    And in the whole book I've been introduced to about 30 functions!!
    Only on about 13 or 15 functions I've learned so far I can even imagine using at all....

    So are just about all of them useful? And if they are, useful for what?

    Thanks,

    Gregory C.
    Gregory C.

  • #2
    It heavily depends on the project your working on, or the work you're trying to do, so IMO it's not possible to generally proclaim that "half of them aren't useful".

    Comment


    • #3
      Yep, and the more you use PHP the more you may think the included functions are useful...
      Ueli

      Comment


      • #4
        If you've only read about 30 functions, you haven't scratched the surface.

        2,294 functions and 234 aliases
        1,228 functions added in PHP4

        Check out the stats.

        Comment


        • #5
          whoah! that many functions?!?

          Whoah.... I thought 30-50 was a lot.... hehehehe you practically don't need to write your own then! sheesh. I think that's more than C++ (I'm an intermediate C++ programmer)...

          Gregory C.
          Gregory C.

          Comment


          • #6
            I guess the nice thing about C++ is that you can include only the header files that you need. Which, I think, would speed it up. Anyone know?

            Comment


            • #7
              i think it would

              including extraneous C++ header files does slow your code down, so yeah, i guess it can make it faster.

              i find php number of functions pretty bad. for example, there is a function to do just about everything. it does not promote good programming, instead, it promotes the ability to use a bunch of functions.

              thats why i feel perl is a better language. it has just the right number of built in functions that are pretty standard (simple math functions, sqrt, tan, atan, rand, srand, file i/o functions, open, close, opendir, closedir, readdir, and so on) those functions are pretty much a part of the C++ STL, so even in C++, it would be possible to do everything in perl (regex's would be a lot harder though).

              anyway, perl has the necessary functions built in, and then CPAN which allows programmers to use modules that specialize in one area.

              for example, to connect to a database, use the perl DBI, that way, you don't have to have so many functions that you don't need included into your script already.

              thats just my $0.02.

              -Vic

              Comment


              • #8
                Don't forget that not all the functions mentioned on php.net will be compiled in to your install...when PHP is compiled you specify what features you need and those functions are compiled in.

                Comment


                • #9
                  Yeah, the number of PHP functions is pretty ridiculous....

                  Even though PHP is my second favorite language (C++ is my favorite) and PHP is fun to use, but the funtions are pretty ridiculous...

                  I think it would save time if the functions were in a .h file - like iostream.h or something...

                  While I'm here, does anyone know why PERL is named PERL? I know PERL stands for "Practical Extractable and Report Language" but that doesn't really cut it for me. What does Practical Extractable and Report Language mean? Report what? Extract what?

                  Gregory C.
                  Gregory C.

                  Comment


                  • #10
                    Actually its "Practical Extraction and Report Language".

                    Perl.com says this:
                    "Perl is a language optimized for scanning arbitrary text files, extracting information from those text files, and printing reports based on that information."

                    Comment


                    • #11
                      actually

                      Actually, "Perl is designed to make the easy jobs easy and the hard jobs possible. -Larry Wall"

                      Hah. Nah, Perl is an awesome language that allows you to do anything from basic string manipulation to OpenGL programming.

                      Perl was not designed for the web, as PHP was, so you will find it not as easy to use sometimes.

                      Perl, unlike PHP (yet), has a place called CPAN, or Comprehensive Perl Archive Network, where people have gone and submitted source code and modules. There are over 2500 modules, and you will most likely be able to find one that suits your needs.

                      Several well known modules:

                      The NET modules
                      The LWP modules
                      The Perl DBI
                      The Socket modules

                      Anyway, Perl is probably best known as the first language to fully implement regular expressions, well. Larry Wall, who is a best, btw, originally wrote perl (notice the small caps, Perl the language is capitalized, perl the interpreter is not) back in 1987, and it has grown to a user base of more than a million people.

                      Right now, there is a group, called the p5p, or Perl 5 Porters, that work on porting perl, along with updating it and so forth.

                      In your quest to learn Perl, you should do several of the following:

                      1. visit www.perl.com
                      2. purchase Programming Perl III Edition, by Larry Wall, Randal Schwartz, and Tom Christiansen from O'Reilly and Associates. Best Perl book out there.
                      3. Look at other O'Reilly perl titles, and decide which other ones will suit your needs.
                      4. Keep asking questions.
                      5. Visit www.tek-tips.com. Another forum that has several sub forums on Perl, which I am one of the Masters of , and the other Masters can help you there. Very good site.

                      Thats about all I have to say, anyone else care to add more?

                      -Vic

                      Comment


                      • #12
                        The one advantage of functions in the langauge is that they will be executed faster as they don't have to be interpretted, e.g. the DBI for perl has to be interpretted before running, wheras the DB functions in PHP are ready to roll so to speak.

                        PHP does have a lot of functions, but what you have to remember is that most are not compiled in by default and quite a few of them are for niche areas, so it's not a case of not having to write your own functions.

                        PHP does have an equivelant of CPAN, it has PEAR but it's just not as popular by a long way yet.
                        Karl Austin
                        UK Web Hosting and Servers :: KDA Web Services Ltd.
                        Specialists in Custom Solutions

                        Comment


                        • #13
                          krs-one, ever hear of PEAR?
                          "PEAR is a code repository for PHP extensions and PHP library code inspired by TeX's CTAN and Perl's CPAN."

                          Comment


                          • #14
                            whoops, someone beat me

                            Comment


                            • #15
                              thanks so much for all the replies...

                              Thanks so much everyone! lol, I'd learn PERL, but as it is I'm already learning Intermediate/Advanced PHP, MySQL, and C++ - so I'm a bit overloaded right now. Also I've got to graduate out of highschool in a year so things are pretty hectic right now (I'm 14 as of this moment).

                              Yeah, I will get around to learning PERL, but I'll probably be learning more C++ in a College after I get out of Highschool as Valedictorian - but I want to learn XML too. Oh yeah, and Java too to add to the collection :-)

                              Gregory C.
                              Gregory C.

                              Comment

                              widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                              Working...
                              X