SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast konsama's Avatar
    Join Date
    Jun 2007
    Location
    Sweden
    Posts
    95
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Fatal error: Call to undefined function

    Fatal error: Call to undefined function formatMsg1() in C:\Websites\bat2\library\Customized\ZFiA_DbMetric.php on line 11
    I'm trying to build and insert my own class file for the very first time in my Zend Framework project. Then I got that error, so I was hoping it's because of my weak understanding of OOP. Because if it's ZF specific then things can turn messy, I'm hoping it's not ZF specific.


    C:\Websites\bat2\public\index.php
    http://pastebin.com/m4e47f439

    PHP Code:
    //______________//
    //  Customized  //
    //______________//

    /* Create database metrics */
    require_once '../library/Customized/ZFiA_DbMetric.php';
    new 
    ZFiA_DbMetric


    C:\Websites\bat2\library\Customized\ZFiA_DbMetric.php
    http://pastebin.com/m4494e043

    PHP Code:
    class ZFiA_DbMetric
    {

        public function 
    __construct()
        {
            
    // 1. Howto call on a function in here?
        
            
    formatMsg1();
        }

        public function 
    formatMsg1()
        {
                     ....
                     ....
                     ....
             } 

  2. #2
    SitePoint Evangelist
    Join Date
    Jun 2006
    Location
    Wigan, Lancashire. UK
    Posts
    523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    //______________//
    //  Customized  //
    //______________//

    /* Create database metrics */
    require_once '../library/Customized/ZFiA_DbMetric.php';
    $instance = new ZFiA_DbMetric
    otherwise, how are you going to reference your new ZFiA_DbMetric


    PHP Code:
    class ZFiA_DbMetric
    {

        public function 
    __construct()
        {
            
    // 1. Howto call on a function in here?
        
            
    $this->formatMsg1();
        }

        public function 
    formatMsg1()
        {
                     ....
                     ....
                     ....
             } 
    Because you're trying to call the method in the current instance
    ---
    Development Projects:
    PHPExcel
    PHPPowerPoint

  3. #3
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Hmmm, I'm not sure the Zend Framework is a wise choice to be starting with if you are just getting into PHP. ZF is an advance framework for core (backend) application developers. I think you would probably be better off starting with small packages of procedural code and building frontends.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  4. #4
    SitePoint Enthusiast konsama's Avatar
    Join Date
    Jun 2007
    Location
    Sweden
    Posts
    95
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mark>>>
    Thanks Mark that got rid of the errors. Now I just have to ask the ZF people how to connect things correctly in the MVC. So that my DbMetric class file works as intended.




    logic>>>
    You're absolutely right! I had some outside help though the first time I tried Zend's official so called "Quickstart guide". That didn't go so well, and later when they added that Data Mapper pattern in the mix you will have to be some kind of ZF guru to follow along what happens in this so called Quickstart guide.

    1.)
    However before this when I was an absolute PHP beginner I bought Harry Fuecks's:
    "PHP Anthology - OOP Solutions - volume 1 & 2"
    and in those books he emphasized a lot on leaving Procedural behind and going to OOP from the get go. So I read this book during weekends without much coding for almost 1,5 year.


    2.)
    Then I did a small hobby project that went incomplete with a professional .Net programmer from the outside as my mentor. He helped me get by those weird concepts like MVC and OOP on a basic level.


    3.)
    Then I stumbled on ZF and bought Rob Allen's:
    "Zend Framework in Action"
    and spent some 2 years reading this thing during weekends, again without much coding.

    So after almost 3,5 years of reading about PHP OOP and ZF I'm just beginning with making my hands dirty. It's like swimming between two islands. I've swam halfways at this stage, and swimming back will take as much energy and time as it will take me swimming to the ZF goal.
    In other words I'm already screwed.


    PS.
    For those who want to get started with ZF the quickest use Akrabat's tutorial instead of Zend's horrible Quickstart guide.
    http://akrabat.com/zend-framework-tutorial/

    Then you just implement the things that Rob has written in the somewhat outdated book with some modifications. ZF books gets outdated after about 6 months it's normal it's not the authors fault it's Zend's fault.
    Still I find Rob's book useful to me.


Tags for this Thread

Bookmarks

Posting Permissions

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