473,786 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Windows PHP/Apcahe config question - #! vs. extensions in registry

I am developing in PHP on a Windows environment but deploying to a *nix
flavor.

I would like to use the extension recognition in Apache in my local
environment for cgi, and have set the "ScriptInterpre terSource" value
to "registry" in my Apache config. That said, I need the "#!" line in
my scripts so when I upload them to their "live" directory, the server
can find the php executable.

When I try to run a script locally that has the "#!" line first,
however, I am given this output and warning:

#!/usr/bin/php4
"Warning: Cannot modify header information - headers already sent by
(output started at..." etc.

It seems Apache gleefully delivers the first "#!" line as content. Is
there any way, other than stripping this line, to avoid this? Or do I
need to go back to the old Unix style config, "ScriptInterpre terSource
script"?

-Jeff

Jul 17 '05 #1
3 1766
If you add to the very top of your page the ob_start(); function in
PHP, that will start an output buffer, so header information will not
be sent until the entire page has been processed.

Just make sure to add ob_end_flush(); to the very end of your page, so
it will empty the buffer.

Jul 17 '05 #2
<je**@evansdata .com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
I am developing in PHP on a Windows environment but deploying to a *nix
flavor.

I would like to use the extension recognition in Apache in my local
environment for cgi, and have set the "ScriptInterpre terSource" value
to "registry" in my Apache config. That said, I need the "#!" line in
my scripts so when I upload them to their "live" directory, the server
can find the php executable.

When I try to run a script locally that has the "#!" line first,
however, I am given this output and warning:

#!/usr/bin/php4
"Warning: Cannot modify header information - headers already sent by
(output started at..." etc.

It seems Apache gleefully delivers the first "#!" line as content. Is
there any way, other than stripping this line, to avoid this? Or do I
need to go back to the old Unix style config, "ScriptInterpre terSource
script"?

-Jeff


Use an auto_prepend file and an auto_append file. In the former, turn on
output buffering with a call to ob_start(). In the latter, strip off the #!
line from the captured output with preg_replace() and echo it.

Both settings are in php.ini.
Jul 17 '05 #3
Thanks, Chung (and music), this ended up doing the trick:

<snip from prepend>

<?php
function shbstrip($buffe r){
return (preg_replace("/^#!.+\n/", "", $buffer, 1));
}
ob_start("shbst rip");
?>

</snip>

<snip from append>

<?php
ob_end_flush();
?>

</snip>

Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
3773
by: Jonathan Polley | last post by:
I have one account on a WindowsXP machine that refuses to run IDLE (or any other python script that uses Tk). Other people can login to that PC and IDLE runs just fine, so it is not an installation issue. When the person who has the problem logs into another PC the problem follows them. Any ideas as to what might me wrong? This is the traceback from IDLE: C:\Python20\Tools\idle>..\..\python.exe idle.py Traceback (most recent call...
16
2323
by: Paul Rubin | last post by:
As what must be penance for something or other, I'm needing to release a Python app for use under Windows XP. Please be gentle with me since I'm a Un*x weenie and the only thing I've had much practice with under Windows is rebooting it. My app contains three different programs (say alice.py, bob.py, and carol.py) that need to be independently launchable, and a dozen or so other .py files that get imported into those first three. What...
13
3229
by: joe215 | last post by:
I want my users to send emails from a Windows app that I am developing in Visual Basic.NET 2003. I found a good example of sending email to a SMTP server using the SmtpMail class. However, using this, it seems, that the user must install IIS on their computer. Isn't there a class that will detect whatever mail server is available on a computer and use that? How do I create this functionality without having the user add any other...
3
3718
by: Danny | last post by:
Hi I just have a quick question. One of our Windows based application uses the registry for configuration type options and some other things. I want to modify our application to move to use a XML file instead of the registry. The other engineer argues that it is faster and easier to manipulate the registry than File I/O operations with the XML file. I just wanted ask you guys what are the strengths and weaknesses with
5
12950
by: Dhilip Kumar | last post by:
Hi All, I'm writing a Windows Service app using C#. I need to read some configuration settings before the service starts up. These settings will be used by the service in its operation. Question is, which is the best way to store & retrieve the settings? I'm thinking of storing it in the registry in HKLM\Software\ServiceName and access it using the Registry class in the "public ServiceName()" method. I'm instructing the service...
2
4183
by: =?Utf-8?B?SnJ4dHVzZXIx?= | last post by:
I just started using Windows Live OneCare, I had been using Norton, but was unable to fix the problems I was having. I have yet been unsuccessful with OneCare as well. I keep getting the same warning from OneCare, one is for Adware, the other is for a trojan, I clean both, but almost immediatly, I get the same warning? My Windows Defender is also shut down, not by me as I have no idea how to do this(or to turn it back on), but am still...
0
978
by: dipalichavan82 | last post by:
i created windows service with timer in which i m deleting files of specific extensions on client m/c n putting on server .i m taking values for 1.list of file extensions dat should be considerd 2.destination path on server 3.timer interval from windows registry. i m programmatically creating key-value pairs in windows registry. when i created keys like this: Local m/c--s/w--serverpath local m/c --s/w--extensions local...
0
30247
AmberJain
by: AmberJain | last post by:
Windows Autorun FAQs: List of autostart locations Linked from the Original article- "Windows Autorun FAQs: Description". Que: Can you list all the autostart locations for windows? Ans: Here is a comprehensive list of all autostart locations for Windows OSes: NOTE : These are some abbreviations used in this list. Please note them carefully: HKCU = HKEY_CURRENT_USER HKLM = HKEY_LOCAL_MACHINE
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10360
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10163
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9960
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7510
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5397
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5532
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4064
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.