Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8302713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:21:09+00:00 2026-06-08T17:21:09+00:00

I thought I can call a method directly with classname::method but it didn’t work.

  • 0

I thought I can call a method directly with classname::method but it didn’t work. How is this possible? I traced the function call with xdebug but it gives me an error. Would it be a problem when the method needs some class variable?

This works:

    $a = new export_csv();
    $a->dl_csv();

This don’t: export_csv::dl_csv();

I’ve added public static to my method to no avail. I don’t get anything in the log files and xdebug stop working without an error message? Is this normal? My class includes some class and connect to my database and pull and echo some rows?

 require_once(PATH_t3lib.'class.t3lib_db.php');
 require_once(PATH_t3lib.'class.t3lib_div.php');
 require_once(PATH_t3lib.'utility/class.t3lib_utility_math.php');

 class export_csv 
 {
     var $filename = 'meinname.csv';

     public static function dl_csv()
     {
        // bitte nicht ändern muß zur laufzeit geladen werden
        include(PATH_typo3conf.'localconf.php');

        $GLOBALS['TYPO3_DB'] = t3lib_div::makeInstance('t3lib_DB');
        $GLOBALS['TYPO3_DB']->connectDB($typo_db_host, $typo_db_username,   
            $typo_db_password, $typo_db);

        session_start();
            $targetCat = mysql_real_escape_string($_SESSION['targetCat']);

            // calculate the number of rows for the query. We need this for paging the 
            result
            $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(  'V.title VT, V.uid VU,  
            S.title ST, S.uid SU, S1.uid S1U, S1.title S1T',
                                                    'tx_category V
                                                    INNER JOIN tx_category S ON  

                                                    V.parent_category=S.uid
                                                    INNER JOIN tx_category S1 ON 
                                                    S.parent_category=S1.uid',
                                                    'V.uid='.$targetCat.' OR S.uid='.
                                                     $targetCat.' OR S1.uid='.
                                                     $targetCat.
                                                    ' AND V.deleted=0 AND V.hidden=0',
                                                    '',
                                                    '',
                                                    ''
                            );                      
    $arrcount=0;
    while ( $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res) )
    {
        $categories[] = mysql_real_escape_string($row["VU"]);
        ++$arrcount;
    }

    header("Pragma: public");
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Cache-Control: public");
    header("Content-Description: File Transfer");
    header("Content-Type:text/comma-separated-values");
    header("Content-Transfer-Encoding: binary");
    header("Content-Disposition: attachment; filename=$this->filename");

    if ( $arrcount )
    {
        $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*',
                                                      'tx_download',
                                                      'category IN('.implode(",",
                                                      $categories).")",
                                                      '',
                                                      "",
     ""                                                  
                                                    );
        while ($row = mysql_fetch_assoc($res) )
        {
            $s = array ();
            $s[] = $row['1'];
            $s[] = $row['2'];
            $s[] = $row['3'];
            $s[] = $row['4'];
            $s[] = $row['5'];

            echo '"'. substr ( implode ( '","', $s ),0,strlen ( implode ( '","', $s) ) - 2  ) . "\r\n";

        }       
    }
  }
 }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T17:21:12+00:00Added an answer on June 8, 2026 at 5:21 pm

    Methods defined as static, which therefore cannot make use of instance properties/methods (via $this) can be called statically via:

    ClassName::methodname();
    
    // Static method definition:
    public static function methodname() {
      echo "I'm the method, I don't use \$this in any way!";
      // Any attempt to use $this in here would result in error.
    }
    

    Review the PHP documentation on static methods and properties

    Update after seeing mode code:

    Your dl_csv() function accesses $this->filename in the output headers, which is invalid inside a static call.

    // Can't do this!
    header("Content-Disposition: attachment; filename=$this->filename");
    

    Instead, you would need to define the $filename as a static property as well and call via self:::

    // Top of the class:
    // Instead of the old PHP4 var keyword, define $filename as a public static property
    public static $filename = 'meinname.csv';
    
    // Later...
    // Inside your method header() call:
    header("Content-Disposition: attachment; filename=" . self::$filename);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I thought I have seen this somewhere but can't find it any more on
Okay at first I thought this would be pretty straightforward. But I can't think
I thought it was alias for simple foreign key relation ,but seems not. Can
This is a question about best practices i guess but it applies directly to
I wanted to know if you can call server side method using JavaScript or
I have a multi-module project. I thought I can compile only a single module
How can you add a click event to dynamically created menu item? I thought
I can't find anything definite using my favourite tool , however I thought I
How can I get the following test to pass with NHibernate? I thought it
How can we detect if a directed graph is cyclic? I thought using breadth

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.