php-general Digest 30 Jul 2009 21:25:35 -0000 Issue 6258

Topics (messages 296050 through 296075):

stdClass - A newbie question
        296050 by: MEM
        296051 by: Bouz Alexander
        296053 by: MEM
        296066 by: Shawn McKenzie

Word and UTF-8 (cyrillic, chinese, ...)
        296052 by: Sascha Meyer

Re: fileinfo returning wrong mime type for Excel files
        296054 by: Christoph Boget
        296056 by: Peter Ford
        296057 by: b
        296058 by: Christoph Boget
        296059 by: Christoph Boget
        296060 by: Ashley Sheridan
        296061 by: Christoph Boget
        296062 by: Bob McConnell
        296063 by: Ashley Sheridan

Freeing Memory
        296055 by: Anton Heuschen
        296065 by: Dan Shirah

Re: Asterisk anyone?
        296064 by: Per Jessen

Re: preg_match too greedy
        296067 by: Ben Dunlap
        296068 by: Ben Dunlap

regex - filtering out chinese utf8 characters
        296069 by: Merlin Morgenstern
        296071 by: Stuart Connolly
        296075 by: Daniel Kolbo

PHP 5.3 IIS 5.1 not working...help!
        296070 by: Fred Silsbee

Re: Page or URL function? (RESOLVED)
        296072 by: Miller, Terion
        296073 by: Jim Lucas
        296074 by: Ben Dunlap

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
Hello everybody, 


In this class sketch:


<?php

class Pagination {

    ...
      
        public static function Pagination ($total_records, $limit, $page)


        {

          $total_pages = ceil($total_records / $limit);

        $page = max($page, 1);

        $page = min($page, $total_pages);

        $offset = ($page -1) * $limit;


        
        $pagi_obj= new stdClass;

        $pagi_obj->total_pages = $total_pages;

        $pagi_obj->offset = $offset;

        $pagi_obj->limit = $limit;

        $pagi_obj->page;



        return $pagi_obj;

        

    }  

    
}


Why do the author used a stdClass ?
What are the advantages of using a stdClass?

Since we are already inside a class, why do we need to create a new object
from another class, inside this one? 
Why do we keep the values passed as params on method Pagination inside this
stdClass object, and not inside Pagination own properties for example? 

Any help clarifying this, knowing that I'm a newbie,

Regards,
Márcio


--- End Message ---
--- Begin Message ---
Hello Márcio,

stdClass is simply an empty class, without any properties or methods.

The object in the code sample is used to return multiple values at once. He 
could also have used an associative array to achieve that, but by choosing an 
object, he shows his affinity to the object oriented programming style.

The empty stdClass has the advantage of being a "blank" class. You can assign 
new properties or methods without minding about properties and methods that 
already exist in the class.
Besides that, it also doesn't use much memory. (Don't see that as performance 
boosting tip! There are much better ways to do that. Besides that, 
comprehensible design > performance.)

By the way, there are many reasons for creating objects inside of other 
objects. This should not be considered an exception. I don't know where this 
code belongs to, so I can't clear out if it is good or bad OOP style.

Just think about everything in classes and objects - even return values or 
other things, that you would normally consider as "volatile". (eg. a network 
connection)

Have a nice day,
Alex




____________________________________
Austrian Optic Technologies GmbH
Eisgrubengasse 2-6, A-2334 Vösendorf/Austria
Firmenbuch Nr.: FN 93629s
Firmenbuchgericht: Landesgericht Wien
UID-NR.: ATU 14976908
 
Disclaimer: Diese Nachricht ist ausschließlich für den bezeichneten Adressaten 
oder deren Vertreter bestimmt. Sollten sie nicht der vorgesehene Adressat 
dieser E-Mail sein, so bitten wir Sie, sich mit dem Absender der E-Mail in 
Verbindung zu setzen. Jede Form der unauthorisierten Nutzung, Veröffentlichung, 
Vervielfältigung oder Weitergabe dieser E-Mail ist nicht gestattet.
This message is exclusively intended for the designated recipient or his 
representatives. If you are not the designated recipient of this e-mail, we 
kindly ask you to notify the sender of this e-mail. Any form of unauthorized 
use, publication, duplication or dissemination of this e-mail is prohibited. 



Von: MEM [mailto:tal...@gmail.com] 
Gesendet: Donnerstag, 30. Juli 2009 12:21
An: php-gene...@lists.php.net
Betreff: [PHP] stdClass - A newbie question

Hello everybody, 


In this class sketch:


<?php

class Pagination {

    ...
      
        public static function Pagination ($total_records, $limit, $page)


        {

          $total_pages = ceil($total_records / $limit);

        $page = max($page, 1);

        $page = min($page, $total_pages);

        $offset = ($page -1) * $limit;


        
        $pagi_obj= new stdClass;

        $pagi_obj->total_pages = $total_pages;

        $pagi_obj->offset = $offset;

        $pagi_obj->limit = $limit;

        $pagi_obj->page;



        return $pagi_obj;

        

    }  

    
}


Why do the author used a stdClass ?
What are the advantages of using a stdClass?

Since we are already inside a class, why do we need to create a new object
from another class, inside this one? 
Why do we keep the values passed as params on method Pagination inside this
stdClass object, and not inside Pagination own properties for example? 

Any help clarifying this, knowing that I'm a newbie,

Regards,
Márcio


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
> By the way, there are many reasons for creating objects inside of other
> objects. This should not be considered an exception. I don't know where
> this code belongs to, so I can't clear out if it is good or bad OOP
> style.

I do not intend to public judge the author, but the original article is here, 
just for proper credit:
http://www.phpro.org/tutorials/Pagination-with-PHP-and-PDO.html
 
 
> Just think about everything in classes and objects - even return values
> or other things, that you would normally consider as "volatile". (eg. a
> network connection)

It would be a nice exercise to practice. :) Thanks for the tip.


And thanks a lot for the reply, I'm almost there... one last newbie question:

When we have something like this:
Class Pagination 
{
        Public static function Pagination ($limit, $total_records, $page)
        {
                $pagi_obj= new stdClass;

                $pagi_obj->total_pages = $total_pages;

                $pagi_obj->offset = $offset;

                $pagi_obj->limit = $limit;

                $pagi_obj->page = $page;



                return $pagi_obj;
...

How can we, later, have something like this, for example:
$pagination_obj=Pagination::Pagination(some params)
$pagination_obj->offset;

?

I mean:
When we instantiate the class by doing: 
$pagination_obj=Pagination::Pagination(some params) 

We will have an object ($pagi_obj) returned where the properties of that object 
will be *referring* to the values passed on the method argument, right?

How does those $pagi_obj properties, can then be accessible by doing 
$pagination_obj->offset; ? I mean, they are attributes of our stdClass object 
(aka pagi_obj), and they are not attributes of our Pagination class, or are 
they?


Thanks in advance,
Márcio





 


--- End Message ---
--- Begin Message ---
MEM wrote:
>> By the way, there are many reasons for creating objects inside of other
>> objects. This should not be considered an exception. I don't know where
>> this code belongs to, so I can't clear out if it is good or bad OOP
>> style.
> 
> I do not intend to public judge the author, but the original article is here, 
> just for proper credit:
> http://www.phpro.org/tutorials/Pagination-with-PHP-and-PDO.html
>  
>  
>> Just think about everything in classes and objects - even return values
>> or other things, that you would normally consider as "volatile". (eg. a
>> network connection)
> 
> It would be a nice exercise to practice. :) Thanks for the tip.
> 
> 
> And thanks a lot for the reply, I'm almost there... one last newbie question:
> 
> When we have something like this:
> Class Pagination 
> {
>       Public static function Pagination ($limit, $total_records, $page)
>       {
>               $pagi_obj= new stdClass;
> 
>               $pagi_obj->total_pages = $total_pages;
> 
>               $pagi_obj->offset = $offset;
> 
>               $pagi_obj->limit = $limit;
> 
>               $pagi_obj->page = $page;
> 
> 
> 
>               return $pagi_obj;
> ...
> 
> How can we, later, have something like this, for example:
> $pagination_obj=Pagination::Pagination(some params)
> $pagination_obj->offset;
> 
> ?
> 
> I mean:
> When we instantiate the class by doing: 
> $pagination_obj=Pagination::Pagination(some params) 

Here you are calling the static method of the Pagination class which
returns the stdClass object which you are assigning to $pagination_obj.

> 
> We will have an object ($pagi_obj) returned where the properties of that 
> object will be *referring* to the values passed on the method argument, right?

$pagi_obj is what is was in the Pagination class, but when it was
returned you assigned it to $pagination_obj.


> How does those $pagi_obj properties, can then be accessible by doing 
> $pagination_obj->offset; ? I mean, they are attributes of our stdClass object 
> (aka pagi_obj), and they are not attributes of our Pagination class, or are 
> they?

The Pagination class built the object for you and assigned those vars to
it.  It then returned the object and you assigned it the name
$pagination_obj.

HTH

-- 
Thanks!
-Shawn
http://www.spidean.com

--- End Message ---
--- Begin Message ---
Hi there,

I am currently struggling in forcing Word to show a UTF-8 encoded document. The 
generated document is a normal web page with generated content from a mysql 
database.
When I remove the header commands, the document with proper russian characters 
is displayed fine in the browser, but when I add
[CODE]
  header ("Content-Type: application/vnd.ms-word;charset=utf-8");
  header ("Content-Disposition: 
attachment;filename=questionnaire_".date("Ymd_his").".doc");
[/CODE]
, Word opens and displays the information as chinese letters instead of 
russian. This also happens for spanish and french special characters, they are 
also incorrectly displayed.

Any clues how I can force Word to display UTF-8 correctly?

Thanks a lot in advance!

Best regards,

Sascha
-- 
Jetzt kostenlos herunterladen: Internet Explorer 8 und Mozilla Firefox 3 -
sicherer, schneller und einfacher! http://portal.gmx.net/de/go/atbrowser

--- End Message ---
--- Begin Message ---
> > /usr/share/file/magic
> /usr/share/file/magic has lots of rules to know its type and its just
> matching it.

I know it has a lot of rules.  Grepping it for excel shows that there
are rules in it for those types of files as well.

> Maybe your file is quite strange . have you tried with other xls files?

Yes, I have; the result is the same for all.

> what does  "file /path/to/my/excel.xls"  say

$ file excel.xls
excel.xls: Microsoft Office Document

Interestingly...

$ file word.doc
word.doc: Microsoft Office Document

So apparently, to the file command, there is no distinction.  That
seems both odd and wrong to me.  But not nearly as wrong as fileinfo
reporting "application/msword" as the mime type of an excel document.

thnx,
Christoph

--- End Message ---
--- Begin Message ---
Christoph Boget wrote:
>>> /usr/share/file/magic
>> /usr/share/file/magic has lots of rules to know its type and its just
>> matching it.
> 
> I know it has a lot of rules.  Grepping it for excel shows that there
> are rules in it for those types of files as well.
> 
>> Maybe your file is quite strange . have you tried with other xls files?
> 
> Yes, I have; the result is the same for all.
> 
>> what does  "file /path/to/my/excel.xls"  say
> 
> $ file excel.xls
> excel.xls: Microsoft Office Document
> 
> Interestingly...
> 
> $ file word.doc
> word.doc: Microsoft Office Document
> 
> So apparently, to the file command, there is no distinction.  That
> seems both odd and wrong to me.  But not nearly as wrong as fileinfo
> reporting "application/msword" as the mime type of an excel document.
> 
> thnx,
> Christoph


Have you tried using 'file -i' from the command line: after all you are looking
for a MIME type with your fileinfo...

Having said that, with file -i on my system, Word documents are
'application/msword' and Excel files are 'application/octet-stream'

-- 
Peter Ford                              phone: 01580 893333
Developer                               fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

--- End Message ---
--- Begin Message ---
On 07/30/2009 08:53 AM, Peter Ford wrote:

Have you tried using 'file -i' from the command line: after all you are looking
for a MIME type with your fileinfo...

Having said that, with file -i on my system, Word documents are
'application/msword' and Excel files are 'application/octet-stream'


Fedora11 (2.6.29.6-213.fc11.i586)

$ file excel.xls
excel.xls: CDF V2 Document, Little Endian, Os: Windows, Version 5.1, Code page: 1252, Author: ??????????????????????????, Last Saved By: ELAN, Name of Creating Application: Microsoft Excel, Last Printed: Sun Nov 6 18:04:20 2005, Create Time/Date: Tue Nov 1 02:56:47 2005, Security: 0

$ file -i excel.xls
excel.xls: application/vnd.ms-excel; charset=binary

Using 5.2.9, the OP's script prints:
application/vnd.ms-excel; charset=binary

I wonder if the problem lies with the documents themselves. Last May, I posted a msg here about how FileInfo was reporting back "application/msword application/msword" for some (but not all) Word docs. I never received a reply about it but came up with a hack to split on the space, if present.
--- End Message ---
--- Begin Message ---
> Have you tried using 'file -i' from the command line: after all you are 
> looking
> for a MIME type with your fileinfo...
> Having said that, with file -i on my system, Word documents are
> 'application/msword' and Excel files are 'application/octet-stream'

$ file -i excel.xls
excel.xls: application/msword

The xls file I am using was generated with Excel (of Office 2007) for
the Mac.  So either you have a different magic file (assuming that's
what the file command uses) than I do or different versions of excel
contain different information.

thnx,
Christoph

--- End Message ---
--- Begin Message ---
>> Having said that, with file -i on my system, Word documents are
>> 'application/msword' and Excel files are 'application/octet-stream'
> Fedora11 (2.6.29.6-213.fc11.i586)
> $ file excel.xls
> excel.xls: CDF V2 Document, Little Endian, Os: Windows, Version 5.1, Code
> page: 1252, Author: ??????????????????????????, Last Saved By: ELAN, Name of
> Creating Application: Microsoft Excel, Last Printed: Sun Nov  6 18:04:20
> 2005, Create Time/Date: Tue Nov  1 02:56:47 2005, Security: 0

Red Hat 4.1.2-14

$ file excel.xls
excel.xls: Microsoft Office Document

I'm not getting all that extra information.

> $ file -i excel.xls
> excel.xls: application/vnd.ms-excel; charset=binary

$file -i excel.xls
excel.xls: application/msword

> I wonder if the problem lies with the documents themselves. Last May, I
> posted a msg here about how FileInfo was reporting back "application/msword
> application/msword" for some (but not all) Word docs. I never received a
> reply about it but came up with a hack to split on the space, if present.

I saw that post and that is something we are getting occasionally as
well.  And it may perhaps be an issue with the documents themselves.
As I stated in a post I just made, the excel document I'm looking at
was created using Office 2007 for the Mac.

thnx,
Christoph

--- End Message ---
--- Begin Message ---
On Thu, 2009-07-30 at 09:51 -0400, Christoph Boget wrote:
> >> Having said that, with file -i on my system, Word documents are
> >> 'application/msword' and Excel files are 'application/octet-stream'
> > Fedora11 (2.6.29.6-213.fc11.i586)
> > $ file excel.xls
> > excel.xls: CDF V2 Document, Little Endian, Os: Windows, Version 5.1, Code
> > page: 1252, Author: ??????????????????????????, Last Saved By: ELAN, Name of
> > Creating Application: Microsoft Excel, Last Printed: Sun Nov  6 18:04:20
> > 2005, Create Time/Date: Tue Nov  1 02:56:47 2005, Security: 0
> 
> Red Hat 4.1.2-14
> 
> $ file excel.xls
> excel.xls: Microsoft Office Document
> 
> I'm not getting all that extra information.
> 
> > $ file -i excel.xls
> > excel.xls: application/vnd.ms-excel; charset=binary
> 
> $file -i excel.xls
> excel.xls: application/msword
> 
> > I wonder if the problem lies with the documents themselves. Last May, I
> > posted a msg here about how FileInfo was reporting back "application/msword
> > application/msword" for some (but not all) Word docs. I never received a
> > reply about it but came up with a hack to split on the space, if present.
> 
> I saw that post and that is something we are getting occasionally as
> well.  And it may perhaps be an issue with the documents themselves.
> As I stated in a post I just made, the excel document I'm looking at
> was created using Office 2007 for the Mac.
> 
> thnx,
> Christoph
> 

To test that, is there any way you could put a blank spreadsheet
document created from that same computer online somewhere so that people
on the list can check to see if it is the file that is being bad and not
your mime types file?

Thanks,
Ash
http://www.ashleysheridan.co.uk


--- End Message ---
--- Begin Message ---
> The xls file I am using was generated with Excel (of Office 2007) for
> the Mac.  So either you have a different magic file (assuming that's
> what the file command uses) than I do or different versions of excel
> contain different information.

I just tried using an excel spreadsheet saved using Office 2003 on XP
and received the same output: application/msword.

thnx,
Christoph

--- End Message ---
--- Begin Message ---
From: Christoph Boget

>> Have you tried using 'file -i' from the command line: after all you
are looking
>> for a MIME type with your fileinfo...
>> Having said that, with file -i on my system, Word documents are
>> 'application/msword' and Excel files are 'application/octet-stream'
> 
> $ file -i excel.xls
> excel.xls: application/msword
> 
> The xls file I am using was generated with Excel (of Office 2007) for
> the Mac.  So either you have a different magic file (assuming that's
> what the file command uses) than I do or different versions of excel
> contain different information.

Those two statements are not mutually exclusive. Both may be true.

Bob McConnell

--- End Message ---
--- Begin Message ---
On Thu, 2009-07-30 at 07:12 -0700, Christoph Boget wrote:
> Well, I didn't want to upload a file to the list.  Putting it in a
> central location where those interested parties could access it would
> be a much better option.
> 
> 
> thnx,
> Chris
> 
> 
> ______________________________________________________________________
> From: Ashley Sheridan <a...@ashleysheridan.co.uk>
> To: Christoph Boget <jcbo...@yahoo.com>
> Sent: Thursday, July 30, 2009 10:05:33 AM
> Subject: Re: [PHP] fileinfo returning wrong mime type for Excel files
> 
> On Thu, 2009-07-30 at 07:04 -0700, Christoph Boget wrote: 
> > > To test that, is there any way you could put a blank spreadsheet
> > > document created from that same computer online somewhere so that people
> > > on the list can check to see if it is the file that is being bad and not
> > > your mime types file?
> > 
> > 
> > Sure.  Do you know of a place I can put it?  What I'm working on is an 
> > intranet.
> > 
> > thnx,
> > Christoph
> > 
> > 
> >       
> You could email it to me, which I presume is better if you replied
> back just to me and not the list?
> 
> 
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
> 
> 
Just copying the list back on in this one now. I don't know of any
places that you could upload a file to off the top of my head. Anyone
have any links?

Thanks,
Ash
http://www.ashleysheridan.co.uk


--- End Message ---
--- Begin Message ---
How  would you go about ensuring the memory is not exhausted when running a
script ?

I have a script, which to make it basic ... reads values from files, I
create an array of values per file then with a foreach insert values into a
table, I have added a line to echo the memory use after each array is done
(after insert is done and the foreach is complete for the file) with: ->
echo "Mem SQL: ".memory_get_usage() . "\n";

It gave me this result below:

Mem SQL: 8341312
Mem SQL: 8461856
Mem SQL: 8693440
Mem SQL: 9327008
Mem SQL: 9798952
Mem SQL: 10238392
Mem SQL: 10604776

As can be seen the mem usage simply grows,

I have added a line after each iteration of the foreach is complete to unset
the vars and array ... thinking this would basically clear up the allocated
memmory used by the array ... and it would start at 0 again for the next
array looped, but obviously this is not quite the answer.

The question is then how do you "clear"  memmory then ?

--- End Message ---
--- Begin Message ---
>
> How  would you go about ensuring the memory is not exhausted when running a
> script ?
>
> I have a script, which to make it basic ... reads values from files, I
> create an array of values per file then with a foreach insert values into a
> table, I have added a line to echo the memory use after each array is done
> (after insert is done and the foreach is complete for the file) with: ->
> echo "Mem SQL: ".memory_get_usage() . "\n";
>
> It gave me this result below:
>
> Mem SQL: 8341312
> Mem SQL: 8461856
> Mem SQL: 8693440
> Mem SQL: 9327008
> Mem SQL: 9798952
> Mem SQL: 10238392
> Mem SQL: 10604776
>
> As can be seen the mem usage simply grows,
>
> I have added a line after each iteration of the foreach is complete to
> unset
> the vars and array ... thinking this would basically clear up the allocated
> memmory used by the array ... and it would start at 0 again for the next
> array looped, but obviously this is not quite the answer.
>
> The question is then how do you "clear"  memmory then ?
>

I don't know what version of SQL you are using, but I have found that using:

mysql_free_result($result);
mssql_free_result($result);
ifx_free_result($result);

Helped my queries run much faster and use less resources. I had something
similar to your script where I would read lines from a huge file and then
insert the contents into my database.  Before adding the above the process
would take 20-30 minutes.  After freeing the results after each insert my
script completed in about 5-8 minutes.

Just add that within your foreach loop after you execute your query that
inserts the info.

Hope that helps.

Dan

--- End Message ---
--- Begin Message ---
Skip Evans wrote:

> Per Jessen wrote:
>> Depends on which data we're talking about.  Asterisk is very
>> flexible.
>> 
> 
> For example, the first screen they want people to be able to
> change data on is:
> 
> call waiting,do not disturb
> and then it looks like numbers (forwarding?)
> unconditional,unavailable,busy
> 
> I'm trying to figure out now are these values stored in a
> regular relational database like MySQL.

I think that is part of the dialplan, which is typically kept in a text
file in /etc/asterisk/extensions.conf or extensions.ael.  I'm not sure
if there is an option to use a database, coz' the dialplan can be quite
complicated.

> But so far the documentation I see is really all about how to
> handle calls, not manage customer data.

Yeah, that is what asterisk is all about - "customer data" depends on
the context.


/Per

-- 
Per Jessen, Zürich (22.8°C)


--- End Message ---
--- Begin Message ---
>>>> echo (preg_match($pattern, $test) != false)
>>
>> The " != false " here is redundant.
> 
> Understood. But what you think is redundancy is, to me, clarity in
> programming. I happen to think that boolean tests shouldn't ride on
> whether or not an array returned from a function is empty or not (or a
> freaking boolean). If what I'm looking for is a "false" then that's what
> I'll test for.

Fair enough, but in that case I think you want "!== false". The expression you
have -- "($x != false)" -- will be true whether $x is 0, NULL, an empty string,
an empty array, or actually FALSE.

But "$x !== false" will only be true in the last case.

Ben

--- End Message ---
--- Begin Message ---
Ben Dunlap wrote:
> have -- "($x != false)" -- will be true whether $x is 0, NULL, an empty 
> string,
[8<]
> But "$x !== false" will only be true in the last case.

Sorry, replace "be true" with "be false" above.

-Ben

--- End Message ---
--- Begin Message ---
Hi there,

I am trying to filter out content that is not ascii. Can I do this with regex? For example:

        $regex = '[AZ][09]';
        if (preg_match($regex, $text)) {
                return TRUE;
        }
        else {
                return FALSE;
        }

The reason I need to do this is that I am doing a mysql query with the text and I need to make sure it is not UTF8. Otherwise I do get following error:

Error: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='

I am new to regex and would be happy for a jump start to get this fixed.

Best regards, Merlin

--- End Message ---
--- Begin Message ---
Hi Merlin,

I think the pattern you're looking for is '/[a-zA-Z0-9]/' which will match all alphanumeric characters.

Cheers

Stuart

On 30 Jul 2009, at 19:13, Merlin Morgenstern wrote:

Hi there,

I am trying to filter out content that is not ascii. Can I do this with regex? For example:

        $regex = '[AZ][09]';
        if (preg_match($regex, $text)) {
                return TRUE;
        }
        else {
                return FALSE;
        }

The reason I need to do this is that I am doing a mysql query with the text and I need to make sure it is not UTF8. Otherwise I do get following error:

Error: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='

I am new to regex and would be happy for a jump start to get this fixed.

Best regards, Merlin

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Attachment: smime.p7s
Description: S/MIME cryptographic signature


--- End Message ---
--- Begin Message ---
Merlin Morgenstern wrote:
> Hi there,
> 
> I am trying to filter out content that is not ascii. Can I do this with
> regex? For example:
> 
>     $regex = '[AZ][09]';
>     if (preg_match($regex, $text)) {
>         return TRUE;
>     }
>     else {
>         return FALSE;
>     }
> 
> The reason I need to do this is that I am doing a mysql query with the
> text and I need to make sure it is not UTF8. Otherwise I do get
> following error:
> 
> Error:         Illegal mix of collations (latin1_swedish_ci,IMPLICIT)
> and (utf8_general_ci,COERCIBLE) for operation '='
> 
> I am new to regex and would be happy for a jump start to get this fixed.
> 
> Best regards, Merlin
> 
You prolly have already been here:
http://www.regular-expressions.info/

But if not, that site is certainly useful for all things regex.

Sorry I can't be of more help for your specific question.

dK
`

--- End Message ---
--- Begin Message ---
http://72.47.28.125:8080/phpinfo.php not working
ERROR:
The website cannot display the page 
 HTTP 500  

IIS 5.1, PHP 5.3 XP Prof SP3 + all updates
PHP 5.2.8 worked great and took a few minutes to install

phpinfo.php is in C:\inetpub\wwwroot 

<?php
phpinfo();
?>

php.ini has:
doc_root = "C:\inetpub\wwwroot" // for IIS/PWS (tried removing the "")
 extension_dir = "ext"
php.ini put into 

    C:\php
    C:\Windows
    C:\Windows\system
    C:\windows\system32
system variable PHPRC set = C:\php

http://72.47.28.125:8080/aspx/abc.aspx works great with IIS 5.1

IIS 5.1 application configuration mappings .php   C:\php\php5.dll (that is all 
there is)
There is no php5isapi file!
home directory = C:\inetpub\wwwroot
web site: IP all unassigned, TCP Port 8080
directory security unchanged: IUSR_<machine name>...allow IIS to control 
password

VC9 versions downloaded and put into C:\php
Microsoft 2008 C++ Runtime (x86) installed
VC9 x86 Non Thread Safe (2009-Jun-30 08:52:54)

C:\php;c:\php\ext put on the end of the path environmental
          system variable


yes I rebooted many times

command line (black window) 
cd C:\php
php -i           generates plenty stuff

I am administrator!

    





      


--- End Message ---
--- Begin Message ---
I Figured it out using this:

         if ($_SERVER['SCRIPT_FILENAME'] = "browse.php" ) {                     
                                    $default = "A";                             
                          }                                                     
                                                        else {                  
                                       $default = "";                           
                         }                                                      
                                                     $letter = 
isset($_GET['letter'])? $_GET['letter'] :"$default" ;


On 7/29/09 4:34 PM, "Ben Dunlap" <bdun...@agentintellect.com> wrote:

Ben Dunlap wrote [TWICE]:
> The $_SERVER global array has this sort of information. The 'PHP_SELF' key
[8<]
> Ben

Very sorry for the double-post. Reply-all in Thunderbird News seems a little
overzealous by default.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--- End Message ---
--- Begin Message ---
Miller, Terion wrote:
> I Figured it out using this:
> 
>          if ($_SERVER['SCRIPT_FILENAME'] = "browse.php" ) {                   
>                                       $default = "A";                         
>                               }                                               
>                                                               else {          
>                                                $default = "";                 
>                                    }                                          
>                                                                  $letter = 
> isset($_GET['letter'])? $_GET['letter'] :"$default" ;
> 

unless you are doing more then what you are showing above.

I would do it like this:

if ( $_SERVER['SCRIPT_FILENAME'] = 'browse.php' ) {
        if ( isset($_GET['letter']) ) {
                $letter = $_GET['letter'];
        } else {
                $letter = 'A';
        }
} else {
        $letter = '';
}

Basically, it is the same thing.  But it doesn't execute the additional
IF statement when it doesn't need to.

Jim

> 
> On 7/29/09 4:34 PM, "Ben Dunlap" <bdun...@agentintellect.com> wrote:
> 
> Ben Dunlap wrote [TWICE]:
>> The $_SERVER global array has this sort of information. The 'PHP_SELF' key
> [8<]
>> Ben
> 
> Very sorry for the double-post. Reply-all in Thunderbird News seems a little
> overzealous by default.
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 
> 



--- End Message ---
--- Begin Message ---
Jim Lucas wrote:
> Miller, Terion wrote:
>> I Figured it out using this:
>>
>> if ($_SERVER['SCRIPT_FILENAME'] = "browse.php" ) {
>>     $default = "A";
>> } else {
>>     $default = "";
>> }
>>
>> $letter = isset($_GET['letter'])? $_GET['letter'] :"$default" ;
> 
> unless you are doing more then what you are showing above.
> 
> I would do it like this:
> 
> if ( $_SERVER['SCRIPT_FILENAME'] = 'browse.php' ) {
>       if ( isset($_GET['letter']) ) {
>               $letter = $_GET['letter'];
>       } else {
>               $letter = 'A';
>       }
> } else {
>       $letter = '';
> }
> 
> Basically, it is the same thing.  But it doesn't execute the additional
> IF statement when it doesn't need to.

They end up slightly different. In your version, Jim, only the page
'browse.php' will examine the GET-parameter called 'letter'.

In Terion's version, any page with this code in it will examine the 'letter'
parameter.

Either one might be appropriate, depending on the context, but they don't have
quite the same effect.

Ben

--- End Message ---

Reply via email to