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 8717481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:18:56+00:00 2026-06-13T06:18:56+00:00

I wrote a very simple PHP extension. Now I want it to read in

  • 0

I wrote a very simple PHP extension. Now I want it to read in a file on startup. Here is my code:

#define PHP_COMPILER_ID  "VC6"


#include <fstream>  
#include "php.h"


int number = 0;
ZEND_FUNCTION(use_html);

//declaration
ZEND_MINIT_FUNCTION(use_html);
zend_function_entry use_functions[] = 
{
    ZEND_FE(use_html, NULL)
    {NULL, NULL, NULL}
};

zend_module_entry use_html_module_entry = 
{
    STANDARD_MODULE_HEADER,
    "First_Extension",
    use_functions,
    ZEND_MINIT(use_html), 
    NULL, NULL, NULL, NULL,
    "1.0.0-tutorial",
    STANDARD_MODULE_PROPERTIES
};

ZEND_GET_MODULE(use_html);

ZEND_FUNCTION(use_html)
{
     bool useHtml;

     if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &useHtml) == FAILURE)
     {
         E_ERROR;
         return;
     }

     if(useHtml)
     {
         php_printf("This string uses <a href='#'>Html</a>");
     }
     else
     {
         int sum = 0;
         int i = 0;
         for(i;i<100000;i++)
             sum += i;

         RETURN_LONG(number);
     }

     return;
}

ZEND_MINIT_FUNCTION(use_html)
{
    std::ifstream infile("file.txt");
    number++;
    return SUCCESS;
}

and the error message is:
Error 5 error C2491: ‘std::endl’ : definition of dllimport function not allowed c:\program files\microsoft visual studio 10.0\vc\include\ostream 1004 1 php_extension1

I also tried to change the order of include, but it didnt help.

EDIT

here is the problematical part from ostream

_CRTIMP2_PURE inline basic_ostream<char, char_traits<char> >&
    __CLRCALL_OR_CDECL endl(basic_ostream<char, char_traits<char> >& _Ostr)
    {   // insert newline and flush byte stream
    _Ostr.put('\n');
    _Ostr.flush();
    return (_Ostr);
    }
  • 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-13T06:18:57+00:00Added an answer on June 13, 2026 at 6:18 am

    I have found a solution: for php extension developement I only added #include <string> in zend_config.w32.h and it compiled fine. for more info: http://social.msdn.microsoft.com/Forums/hu-HU/vcgeneral/thread/94ed21c2-7128-4149-8a8f-05fc195a812c

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have wrote a very simple php upload. But I want to insert image
I just wrote a very simple perl tk script to read a huge text
I want to have a very simple editor for my website that i wrote
I just began learning PHP. I've installed php5 on Linux and wrote very simple
I wrote a script in php. It's very simple, it just multiplies a typed
I have a very simple web synchronization PHP I want to build which basically
I have created a very simple PHP file that does very simple job, it
I wrote a very simple mysql line for my very simple search bar that
I wrote this very simple macro to delete all rows when Column P has
I am trying to learn Android app development and wrote a very simple app

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.