php-general Digest 11 Jun 2008 10:35:27 -0000 Issue 5508

Topics (messages 275211 through 275226):

Re: mssql extension
        275211 by: Shawn McKenzie

Problem with output_buffering directive in cli
        275212 by: Mike Burba
        275218 by: Nathan Nobbe
        275225 by: Mike Burba
        275226 by: Mike Burba

Re: Class & Type Casting
        275213 by: Larry Garfield
        275217 by: Nathan Nobbe
        275220 by: Leurent Francois

Re: class? package?
        275214 by: Larry Garfield
        275216 by: Nathan Nobbe

Re: SPAM SPAM [PHP] Build and Deployment Process
        275215 by: Paul Scott

printer problem with network shared printers
        275219 by: Kasun Denepitiyage

Re: Build and Deployment Process
        275221 by: Colin Guthrie

XML DOM problem with getAttribute(string)
        275222 by: Borden Rhodes
        275224 by: Rob Richards

regular expression to find body text in mobile
        275223 by: Yui Hiroaki

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
Shawn McKenzie wrote:
Mathieu Pelletier wrote:
Hello !
My Workstation/server:
Window XPApache 2.2.4 (win32) PHP/5.2.3SQl Server 2003
I have never been able to load mssql extension in my life...In my php .ini file, I removed the ; correctly : extension=php_mssql.dll Other extensions work fine, for example I use the PDF extension :
extension=libpdf_php.dll
When I call phpinfo(), I can see informations about PDF, but nothing about mssql. I was wondering if I have the good version of the dll in my "ext" directory..Or is SQl server 2003 compatible with XP and the latest version of php?
By the way, SQLServer works fine on my computer.
Thank you very much Mathieu
_________________________________________________________________


You restarted apache after uncommenting the line?

-Shawn

Guess not.

--- End Message ---
--- Begin Message ---
I am using Smarty templates to format HTML emails from the command
line (using cli).  My typical command is:
php filename.php

However, and I am struggling with templates that are greater than 10k.
 It looks like the Smarty output is getting truncated at about 10k.
Smarty uses output_buffering, so I need to be set the output_buffering
directive to "1" or "On" or "1000000", or something other than "Off".
But I have not been able to do that.

I have changed the output_buffering setting in /.../cli/php.ini (as
well as /.../apache2/php.ini & /.../cgi/php.ini for good measure).
And that does seem to have an effect.

Here is what the output from phpinfo() is from the command line:
Directive => Local Value => Master Value
....snip...
output_buffering => 0 => 1000000
output_handler => no value => no value
...snip...

So in other words, when I change the value in my /.../cli/php.ini, the
"Master Value" changes. However, the "Local Value" stays at "0".

In my code, I am testing for the value of output_buffering (using
ini_get("output buffering")), and its value is always "0" (same as the
"Local Value" that is output from the phpinfo().

So my question is...how do I turn on output_buffering correctly from
the command line?  Am I configuring the /.../cli/php.ini file
correctly?  Is something in my code (maybe an included library) maybe
setting that value without me knowing?  Am I looking in the wrong
place / headed in the wrong direction?

Mike

--- End Message ---
--- Begin Message ---
On Tue, Jun 10, 2008 at 10:27 PM, Mike Burba <[EMAIL PROTECTED]> wrote:

> I am using Smarty templates to format HTML emails from the command
> line (using cli).  My typical command is:
> php filename.php
>
> However, and I am struggling with templates that are greater than 10k.
>  It looks like the Smarty output is getting truncated at about 10k.
> Smarty uses output_buffering, so I need to be set the output_buffering
> directive to "1" or "On" or "1000000", or something other than "Off".
> But I have not been able to do that.
>
> I have changed the output_buffering setting in /.../cli/php.ini (as
> well as /.../apache2/php.ini & /.../cgi/php.ini for good measure).
> And that does seem to have an effect.
>
> Here is what the output from phpinfo() is from the command line:
> Directive => Local Value => Master Value
> ....snip...
> output_buffering => 0 => 1000000
> output_handler => no value => no value
> ...snip...
>
> So in other words, when I change the value in my /.../cli/php.ini, the
> "Master Value" changes. However, the "Local Value" stays at "0".
>
> In my code, I am testing for the value of output_buffering (using
> ini_get("output buffering")),


dunno if this was a typo on your part, but shouldnt it be,
ini_get("output_buffering") ?


> and its value is always "0" (same as the
> "Local Value" that is output from the phpinfo().
>
> So my question is...how do I turn on output_buffering correctly from
> the command line?  Am I configuring the /.../cli/php.ini file
> correctly?  Is something in my code (maybe an included library) maybe
> setting that value without me knowing?  Am I looking in the wrong
> place / headed in the wrong direction?


you might not be getting your settings from the ini file you think you are,
or there could be another one in the way.  just for the hell of it, why not
give

php --ini

a shot, see if something unexpected crops up, and maybe poke around in all
of those files.

also, this brings up the point of setting local values on the cli.  im not
sure how to do it.  w/ apache, you can supply a .htaccess file which allows
you to alter values in the 'local' column of the phpinfo() output.  anyone
know how to do it on the cli ?

-nathan

--- End Message ---
--- Begin Message ---
Thanks for ideas, Nathan.

> dunno if this was a typo on your part, but shouldnt it be,
> ini_get("output_buffering") ?
>
yes...was getting tired last night.  but it is correct in the code.

> you might not be getting your settings from the ini file you think you are,
> or there could be another one in the way.  just for the hell of it, why not
> give
>
> php --ini

This is a great idea...and I tried this but I'm using php 5.1.x and
--ini flag is not available until 5.2.something. <sigh>

> also, this brings up the point of setting local values on the cli.  im not
> sure how to do it.  w/ apache, you can supply a .htaccess file which allows
> you to alter values in the 'local' column of the phpinfo() output.  anyone
> know how to do it on the cli ?

Exactly my thoughts...anyone out there know?

--- End Message ---
--- Begin Message ---
I think I solved this issue by using the -d option on the commandline.

When I use:
php -d output_buffering=On ./filename.php

the local value / active value of output_buffering is correct.

MKB

On Wed, Jun 11, 2008 at 5:54 AM, Mike Burba <[EMAIL PROTECTED]> wrote:
> Thanks for ideas, Nathan.
>
>> dunno if this was a typo on your part, but shouldnt it be,
>> ini_get("output_buffering") ?
>>
> yes...was getting tired last night.  but it is correct in the code.
>
>> you might not be getting your settings from the ini file you think you are,
>> or there could be another one in the way.  just for the hell of it, why not
>> give
>>
>> php --ini
>
> This is a great idea...and I tried this but I'm using php 5.1.x and
> --ini flag is not available until 5.2.something. <sigh>
>
>> also, this brings up the point of setting local values on the cli.  im not
>> sure how to do it.  w/ apache, you can supply a .htaccess file which allows
>> you to alter values in the 'local' column of the phpinfo() output.  anyone
>> know how to do it on the cli ?
>
> Exactly my thoughts...anyone out there know?
>

--- End Message ---
--- Begin Message ---
On Tuesday 10 June 2008, Leurent Francois wrote:
> I was asking myself if there was a good reason this syntax not to work
>
> class string_extented{
> function __construct($str){
> $this->contents=$str;
> }
> function __toString(){
> return $this->contents;
> }
>
> }
>
> //that's working fine
> $test= new string_extended("this is my anonymous string");
> echo $test;
>
>
> /that's not working, but should'nt it be the case ?
> $test = (string_extended) "This is my anonymous string";
> echo $test;
>
> I'll find this very usefull :x, it's just a syntax ehancement nope ?

Casting only works between "easily convertable" types.  A string does not 
easily convert to a classic object.  One could ask if it would just pass to 
the constructor, but it doesn't.  I don't know if there's a technical reason 
for that or if just no one implemented it, but the short answer is "The 
language doesn't do that."

(What may be confusing you is __toString(), which only works for *reading* if 
you *already have an object* and then use it in a string context.  You don't 
already have an object and are trying to *write*, so the __toString() does 
nothing.)

-- 
Larry Garfield                  AIM: LOLG42
[EMAIL PROTECTED]               ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

--- End Message ---
--- Begin Message ---
On Tue, Jun 10, 2008 at 5:13 AM, Leurent Francois <[EMAIL PROTECTED]>
wrote:

> I was asking myself if there was a good reason this syntax not to work
>
> class string_extented{
> function __construct($str){
> $this->contents=$str;
> }
> function __toString(){
> return $this->contents;
> }
>
> }
>
> //that's working fine
> $test= new string_extended("this is my anonymous string");
> echo $test;
>
>
> /that's not working, but should'nt it be the case ?
> $test = (string_extended) "This is my anonymous string";
> echo $test;
>
> I'll find this very usefull :x, it's just a syntax ehancement nope ?


in some languages, such as java, the syntax "", is merely syntactic sugar
for creating an instance of a class, say String.  in such languages creating
a subclass of String, would give you the ability to cast in the way you have
done.  however, in php a string is a primitive type and nothing more,
therefore the above will not work.

furthermore, i dont see what enhancement youre adding to strings in the code
fragment is anyway.  you can still pass around string variables and echo
them at any time.  one thing i have used __toString() for is in a subclass
of SimpleXMLElement, where SimpleXMLElement::asXML() returns a string
representation of the instance, i have added

public function __toString() {
  return $this->asXML();
}

to make it a bit more elegant, imho ;)

and lastly, as a side note / mini rant; since ive been mumbling about java
so much lately, i would like to take a second to mention that objective-c,
in particular the apple cocoa framework, is another language that supports a
string literal syntax for a class.  an NSString instance can be represented
literally by @""; and im sure there are other examples out there as well.

-nathan

--- End Message ---
--- Begin Message ---
> One could ask if it would just pass to
> the constructor, but it doesn't.  I don't know if there's a technical 
> reason
> for that or if just no one implemented it, but the short answer is "The
> language doesn't do that."

That's what i was asking about, when trying to "cast" something into a non 
native type ( ie a class ), just fire the constructor. Would'nt it be great 
?

$myvar=(array) somefunc();
$myvar=(myarrayextented) somefunc();

( what should be exactly the same as  )
$myvar=new myarrayextented(somefunc());

But with a lot more of coolness ! 



--- End Message ---
--- Begin Message ---
On Tuesday 10 June 2008, Shelley wrote:
> Hi all,
>
> If you are designing with OO principles, could you give an explanation of
> what is the difference classes and packages?
>
> Several principles talks about classes and packages, such as:
> The classes in a package are reused together. If you reuse one of the
> classes in a package, you reuse them all.
>
> but few explains the difference between them.
>
> When I was summarizing the OO principles, that question confused me:
> http://phparch.cn/index.php/php/43-php-advanced-programming/170-principles-
>of-object-oriented-design
>
> Thanks in advance. :)

A class is a syntactic way of grouping behavior and data together in an 
encapsulated fashion (at least that's the PHP definition).  

A formal package is a syntactic way of grouping related classes together, 
either for easier distribution, somewhat tighter coupling, or syntactic 
sugar.  For instance, you could have 5 classes that make up your "Database 
abstraction" package; they're all discrete, but all work in concert.

PHP does not have a syntactic "package" concept.  The closest thing would be 
namespaces as implemented in PHP 5.3, but that's not out yet.  Many systems 
emulate packages with verbose class naming (eg, Database_Connection, 
Database_Query, Database_Transaction, Database_Query_Select, etc.), but I 
personally find that ugly. :-)

-- 
Larry Garfield                  AIM: LOLG42
[EMAIL PROTECTED]               ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

--- End Message ---
--- Begin Message ---
On Wed, Jun 11, 2008 at 12:02 AM, Larry Garfield <[EMAIL PROTECTED]>
wrote:

> On Tuesday 10 June 2008, Shelley wrote:
> > Hi all,
> >
> > If you are designing with OO principles, could you give an explanation of
> > what is the difference classes and packages?
> >
> > Several principles talks about classes and packages, such as:
> > The classes in a package are reused together. If you reuse one of the
> > classes in a package, you reuse them all.
> >
> > but few explains the difference between them.
> >
> > When I was summarizing the OO principles, that question confused me:
> >
> http://phparch.cn/index.php/php/43-php-advanced-programming/170-principles-
> >of-object-oriented-design
> >
> > Thanks in advance. :)
>
> A class is a syntactic way of grouping behavior and data together in an
> encapsulated fashion (at least that's the PHP definition).
>
> A formal package is a syntactic way of grouping related classes together,
> either for easier distribution, somewhat tighter coupling, or syntactic
> sugar.  For instance, you could have 5 classes that make up your "Database
> abstraction" package; they're all discrete, but all work in concert.
>
> PHP does not have a syntactic "package" concept.  The closest thing would
> be
> namespaces as implemented in PHP 5.3, but that's not out yet.  Many systems
> emulate packages with verbose class naming (eg, Database_Connection,
> Database_Query, Database_Transaction, Database_Query_Select, etc.), but I
> personally find that ugly. :-)


furthermore, in languages such as java (and likely others) packages have
access levels which are conceptually similar to ppp in classes.  this allows
designers to limit access to certain classes in a given package (duh); it
turns out to be quite useful.  imagine you are a library author and some of
the classes you distribute, you dont intend for your clients to use, well
then, you simply mark those classes as private.

i dont believe the php namespace concept incorporates this feature, nor do i
think its really relevant, in a source based language.  however, i do find
it relevant to the discussion ;D

-nathan

--- End Message ---
--- Begin Message ---
On Tue, 2008-06-10 at 14:56 -0700, VamVan wrote:
> What is the best method to build and deploy php scripts along the different
> environments? You can talk about rpm's and stuff

In my project(s) I use Phing. http://phing.info It is even written in
PHP, so keeping this thread on topic.

--Paul
-- 
------------------------------------------------------------.
| Chisimba PHP5 Framework - http://avoir.uwc.ac.za           |
:------------------------------------------------------------:

All Email originating from UWC is covered by disclaimer 
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm 

--- End Message ---
--- Begin Message ---
hi
im using the winXp as my server OS and i want to release a printout to client local printer. so i tried to use that shred printer using php printer_open() function but i coudnt. so please provide me the best solution for this issue. i can use client side script but i need server side solution.


--
This message contains confidential information and is intended only for the 
individual named. If you are not the named addressee you should not 
disseminate, distribute or copy this e-mail. Please notify the sender 
immediately by e-mail if you have received this e-mail by mistake and delete 
this e-mail from your system. E-mail transmission cannot be guaranteed to be 
secure or error-free as information could be intercepted, corrupted, lost, 
destroyed, arrive late or incomplete, or contain viruses. The sender therefore 
does not accept liability for any errors or omissions in the contents of this 
message, which arise as a result of e-mail transmission. If verification is 
required please request a hard-copy version. Pan Asia Banking Corporation Plc. 
450, Galle Road, Colombo 3, Sri Lanka. www.pabcbank.com


--- End Message ---
--- Begin Message ---
VamVan wrote:
Hello All,

What is the best method to build and deploy php scripts along the different
environments? You can talk about rpm's and stuff

My specific scenario is

Step1:

Developer checks code in to perforce (repo)

Step 2:

Then I need to upgrade my integration instance.

Step 3:

Upgrade QA instance

Step 4:

Upgrade staging Server

Step 5:

Upgrade production machines

What would be the specific build mechanism that I can use for such kind of
environments? I also have db scripts that might alter schema.

Please provide me samples of any scripts that you might have written to
achieve this kid of structure. Any suggestions or scripts will be highly
appreciated.

Personally, I use various branches in our repo to do this kind of roll out. I have various (simple) scripts that do all the updating on the various environments and it's usually just a matter of switching to a different branch.

It kind of depends whether all of your productions environments are under your control or not. If they are then you can do a kind of direct access to your repo on them (security considerations aside).

On production, I personally do a pull from the repop to an offline area on a "master" production server, do rsync dry-runs to online areas (to get the disc cache all warmed up) to each production server (there can be more than one!) and then do a quick: disable, rysnc, update, enable run to do the final deployment.

If we know there are no race type issues in our deployment we can opt to avoid the disable/enable bit of it and just deploy it live.

Not much in the way of attached scripts but that how I do it and it works pretty well :)

As a side note, if you have larger load sites, you'll probably be doing some caching cleverness with APC (or similar), in which case you'll probably want to invalidate some caches before update. In order to prevent spike loading upon enabling again, you may also want to do some kind of "priming" of the caches before opening it all to the public.

Col


--- End Message ---
--- Begin Message ---
Hullo!

I'm having a pig of a time trying to figure this one out:  I have an
XHTML document which I've loaded into a DOMDocument because I want to
add more tags to it.  However, since I live in a bilingual country, I
want to get the document's xml:lang attribute so I know what language
to add my new tags in.

I want to write

$lang = $page->documentElement->getAttribute('xml:lang');
OR
$lang = $page->documentElement->getAttributeNS('xml', 'lang');

but both of these return empty strings, indicating that it cannot find
the xml:lang attribute.  And yet,
$page->documentElement->hasAttributes() returns true and

$page->documentElement->attributes->getNamedItem('xml:lang')->nodeValue;

works correctly.  So why doesn't my preferred code?

With thanks,

--- End Message ---
--- Begin Message ---
Borden Rhodes wrote:
I'm having a pig of a time trying to figure this one out:  I have an
XHTML document which I've loaded into a DOMDocument because I want to
add more tags to it.  However, since I live in a bilingual country, I
want to get the document's xml:lang attribute so I know what language
to add my new tags in.

I want to write

$lang = $page->documentElement->getAttribute('xml:lang');
OR
$lang = $page->documentElement->getAttributeNS('xml', 'lang');

but both of these return empty strings, indicating that it cannot find
the xml:lang attribute.  And yet,
$page->documentElement->hasAttributes() returns true and

$page->documentElement->attributes->getNamedItem('xml:lang')->nodeValue;

works correctly.  So why doesn't my preferred code?

The xml prefix is bound to the http://www.w3.org/XML/1998/namespace namespace.

$lang = $page->documentElement->getAttributeNS('http://www.w3.org/XML/1998/namespace', 'lang');

Rob

--- End Message ---
--- Begin Message ---
Doese any know how to find text in mobile using Regular Expression?
I am using php.

Regards,
Yui

--- End Message ---

Reply via email to