I'm running through a large dataset and am generating/manipulating XML
documents for each record. What's happening is that after a while, I
get a fatal error saying:
Fatal error: Allowed memory size of 167772160 bytes exhausted (tried
to allocate 32650313 bytes)
Each XML file I generate (an mani
>> Does anyone know how (or even if) I can explicitly free the memory
>> used for the DOMDocument? Any help/advice would be greatly
>> appreciated!
> I've had exactly the same problem and couldn't find a way around it; even
> after unsetting every variable in my scripts inside a for/while loop; in
Does anyone know if it's possible, using PHP, to take HTML (either as
an input or from a URL) and generate an image (essentially, create a
screenshot) of that HTML/page? I've looked around but was unable to
find anything and I'm just not sure if it's that there really is
nothing like this out ther
> Well I'm stuck I have the AdminID but now I can't seem to use it to pull
> workorders with that AdminID . I couldn't get your block to work Andrew :(
> I think I'm just not using it right now that I have it...lol
Because there is ambiguity w/r/t the columns you are selecting, you'll
need to use
> >> Because there is ambiguity w/r/t the columns you are selecting, you'll
> >> need to use aliases.
> >> http://dev.mysql.com/doc/refman/5.1/en/identifiers.html
> >> In your code, when you are referencing the column, do so using the
> >> alias. That should solve your problem.
> > I just read it
> > How can you require 8 levels of nesting? surely there must be something
> > wrong or a more efficient algorithm...
> No! It's just that you can't think in 8 dimensions like him.
Yeah, at that point you are dealing with space and time and that's not a
subject of contemplation for everyone. :p
>> Backslash? Seriously? I'm hurt that my suggestion of "¬" (ASCII170 ?)
>> wasn't used. :-(
> Backslash doesn't sound like it will look very pretty
Windows and DOS have been getting away with it for the last 25+ years
so why can't PHP get in on that action? :P
Though I have read the explanation
Is there a reason why you can't programatically set ownership of a
symbolic ink? The following code
if( symlink( TARGET, LINK ))
{
echo 'Successfully created ' . LINK . "\n";
if( @chown( LINK, NEW_UID ))
{
echo 'Successfully changed ownership for ' . LINK . "\n";
if( @chgrp( LINK,
> I have a script that is a result of data entered in a form
> On the script (when I test without data entry), I am getting a warning that
> Warning: Division by zero in .inc.php on line 15.
> The warning is correct, however the viewer cannot access the second script
> without entering the data tha
> The error I am getting is when I am defining a variable.
> (line 15) $percent_difference=($assess_difference)/($assess_value);
> Does this make a difference?
No, it doesn't make a difference. The simple fact is that
$assess_value is either undefined or has been set to 0 at some point.
For it's
I'm wondering if there isn't something out there that crawls through
your codebase and generates a map of (any of) the following:
* What files are include in which scripts
* The relationships between defined classes (eg A extends B)
* What other classes are utilized by which classes (eg, instantia
>> * What files are include in which scripts
> pecl.php.net/package/inclued - an awesome tool, will show you
> includes/require calls to other ones, show you any redundancy (dotted
> lines) etc. helps you clean up any nested and unnecessary includes or
> requires. Rasmus approved(tm)
> use it with
http://us.php.net/manual/en/language.operators.type.php
The instanceof operator was introduced in PHP 5. Before this time
is_a() was used but is_a() has since been deprecated in favor of
instanceof. Note that as of PHP 5.3.0, is_a() is no longer deprecated.
http://us.php.net/manual/en/function.is-
Consider the following:
$finfo = finfo_open( FILEINFO_MIME, '/usr/share/file/magic' );
if( $finfo )
{
$mimeType = finfo_file( $finfo, '/path/to/my/excel.xls' );
finfo_close($finfo);
}
echo $mimeType;
When I run the above, it echoes out "
> > /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 x
> 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: applic
>> 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:
> 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
> I have a possibly-evil idea that gets around type-hinting by
> dynamically declaring decorator classes as children of the real
> classes that need to be timed. You end up with as many "decorators" as
> you have classes that need to be timed, but if this is for dev/QA
> purposes only, that might n
I've read the section in the docs about i/o streams and other related
sections I was able to find but couldn't figure out how to do what I
need. From the command line, I'm trying to pipe stdout in to my php
script which should then see it as input. A simplistic example would
be:
echo bob | myScr
> Isn't it simpler with
> http://www.php.net/manual/en/function.shell-exec.php
> ?
Perhaps. But the command to execute would be relatively arbitrary.
What I'm trying to do is set up a script that will filter the results
of a grep. But what I'm grepping and where I'm starting from would
change.
> Exactly. And if you just want redirected data you can try:
> $data = file_get_contents("php://stdin");
> --or--
> For an array of lines:
> $lines = file("php://stdin");
This is exactly what I was looking for. Thanks Shawn and Ben!
thnx,
Christoph
--
PHP General Mailing List (http://www.php.n
Given the following XML:
I'm using the following query:
$oXPath->query( '//DisplayRef/paramet...@alias="widgetType and
@value="system"]' );
and I'm getting the following error:
Warning: DOMXPath::query() [function.DOMXPath-query]: Invalid predicate
If I remove this pa
> You are missing a quote after widgetType:
Yeah, I realized that about 2 minutes after I sent the message. Man,
I'm dumb. :p I was banging my head against the wall for a while
because of that. I guess when you bring your stupidity public, you'll
find the solution yourself that much quicker. ;)
I've looked through the docs but was unable to find out if this is possible;
I hope it is. Is there a way that you get the size/length of the collection
to be iterated (e.g. the total number of files) without having to iterate
through at least once?
thnx,
Christoph
>
> def not on DirectorIterator afaik, and furthermore, i dont think thats
> supported at the shell / filesystem level even.
Well if the Iterator has the whole of the collection in order to be able to
iterate over it, I would think that it should be able to return the size of
that collection... :
>
> right but the collection is built during iteration.
>
So you're saying that if I add a file to the directory between the time I
instantiate the DirectoryIterator and the time I'm finished iterating
through, that file could be picked up? Or is the instance only going to
contain a list of files
I executed the following test script several times. Each time, in a
separate terminal window, I ran "touch bob.txt" after the script started
echoing out. After the script completed, I deleted bob.txt. During each
execution, not once did bob.txt show up in the output. This makes me
believe that
Ok, so taking the sample code that is on the page
http://us3.php.net/manual/en/language.exceptions.extending.php
Literally, just cutting and pasting the code. When I try to
throw new Exception( 'My Message' );
PHP spits out the following fatal error:
Fatal error: Wrong parameters for Exceptio
I'm curious if the behavior of json_encode() is influenced by the
browser at all. I have a page that returns search results. If I
access the page and perform a search using Chrome, the following error
shows up in the log:
PHP Warning: json_encode() [function.json-encode]: Invalid UTF-8
sequence
> It can have something to do with your browser codification (UTF8,
> ISO-8859-???).
But why would that be the case? Is json_encode() actually encoding
the string differently in each case? And would it encode it
differently if I wrote a script to take the same input and ran it from
the command l
> You should set the charset of your page by meta tag in its head.
Do you have a source of reference to which you point me?
thnx,
Christoph
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
> http://www.w3.org/TR/html4/charset.html
> I hope it can help you.
> PS: json_decode works only in utf8.
I understand charsets. I understand the difference between the
charsets. What I don't understand is how json_encode() is taking the
*exact same input* and behaving differently (breaking in o
> Sorry about the error:
> In this case, you must set IT via meta tag to avoid it.
Ok, let's try this using a different approach. Consider the following
pseudo-code:
Why does the charset of the browser matter one whit to the value of
either $row['name'] or $row['date'] such that it would break
> I am trying to use this while look to assign them to variables:
> $word_1
> $word_2
> $word_3
> ...
> $word_25
This should work for you:
http://us3.php.net/manual/en/function.extract.php
thnx,
Christoph
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.n
Consider the following code:
';
}
}
bob::factory();
$var = 'bob';
$var::factory();
?>
When I run this, "In Factory!" is displayed twice, as I would expect.
So by all accounts, there's nothing wrong with the code. However, when
I run that file through ZendCodeAnalyzer, I get the followin
It seems like when dealing with nodes which have CDATA, I cannot get
access to both the attributes of that node and the CDATA of that node
with the same simplexml_load_string() call. Consider the following:
$previewString =
'';
When passing LIBXML_NOCDATA:
echo '' . print_r( json_decode( json_e
It seems like when dealing with nodes which have CDATA, I cannot get
access to both the attributes of that node and the CDATA of that node
with the same simplexml_load_string() call. Consider the following:
$previewString =
'';
When passing LIBXML_NOCDATA:
echo '' . print_r( json_decode( json_e
> http://us.php.net/manual/en/function.simplexml-load-string.php#80855 maybe?
Thanks for that. I guess I should have scrolled a little further
down. It's so crazy that it works that way. Unless you export the
actual element (and not it's ancestors), you don't see the data at
all.
thnx,
Christo
I looked in the docs but didn't see anything regarding case
insensitivity and I fear the functionality doesn't exist. I'm just
hoping I'm looking in the wrong place.
Is there a way to get ksort to work without regard to case? When I
sort an array using ksort, all the upper case keys end up at th
My company has the following job openings available:
Join in the Adventure.
Yakabod, a web software and services company, is located in a beautifully
restored facility in Frederick, Maryland's historic district. We've
experienced steady growth since starting in 2001. We've set our hearts on
build
>
> Maybe next time you'll have a challenge for me ;) And don't whine about
> how I achieved what I did.
Brilliant! I never would have thought of that. ;)
thnx,
Christoph
The string used below in "$myArrEncoded" is generated in javascript, after
creating the structure and spitting out:
var JSONVar = javascriptVar.toSource();
I can eval JSONVar and work with it as I would be working with the original
javascriptVar so I know the transition back and forth from a stru
Please disregard. Sometimes I weep at my own stupidity... :p
thnx,
Christoph
On 10/19/07, Christoph Boget <[EMAIL PROTECTED]> wrote:
>
> Please take a look at the following code and tell me what I'm doing wrong
> here. I'm just not understanding why this isn't working:
Please take a look at the following code and tell me what I'm doing wrong
here. I'm just not understanding why this isn't working:
array( 'Key 1 1' => array( array( 'Key 1 1 1'
=> 'Value' ),
array( 'Key 1 1 2'
=> 'Value' )),
Consider the following test code:
';
$startTime = microtime( TRUE );
$foundCount = 0;
for( $i = 0; $i <= 1; $i++ )
{
$date = microtime( TRUE );
$key = rand( $date, $date * rand( 1, 5000 ));
if( array key exists( $key, $myArray ))
{
$foundCount++;
}
}
$e
My company has the following job openings available. Be sure to check out
our recruiting video at https://www.yakabod.com/join.html?nav=4. It's a
pretty fun watch. :)
Join in the Adventure.
Yakabod, a web software and services company, is located in a beautifully
restored facility in Frederick
Why does
sprintf( '%.03f', 0.1525 )
return 0.152 while
sprintf( '%.03f', 0.1575 )
return 0.158?
The 4th significant digit in both cases is '5' but in the first case, it's
rounded down but in the second case it is rounded up. Is sprintf() basing
it's decision on the value of the 3rd si
I've been looking through the docs but haven't found an internal function
that does what I'm looking for. Perhaps I missed it? Or perhaps someone
can point me in the right direction? I'm looking for a routine that will
convert tags to lower case. For example, if I have
This is the Page
I've been looking through the docs but haven't found an internal function
that does what I'm looking for. Perhaps I missed it? Or perhaps someone
can point me in the right direction? I'm looking for a routine that will
convert tags to lower case. For example, if I have
This is the Page
> I believe __FILE__ is resolved at compile time, not run-time which
> means what you're seeing is expected behavior. I'm not sure how you'd
> get the name of the file that a function call was made from.
> Could you explain why you need this information in your application,
> and perhaps some
Let's say I have the following 3 files
global.php
one.php
two.php
In each case, what is echoed out for __FILE__ is global.php. Apart from
analyzing the debug_backtrace array, is there any way that myFunc() would
display "one.php" and "two.php" respectively?
thnx,
Christoph
Not wanting to re-invent the wheel, I'm wondering if there is a package out
there that can read in an HTML file and allow you to manipulate and dissect
it much like you can in javascript? For example, functionality similar to
(though, not necessarily the same as) getElementById(), .innerHTML, etc.
Here is the input string I'm using:
{display ref="BYOPPageMetaData" id="3"}
{display ref="ResourceList" id="0"}
>
> > that one of the nodes has an id of 'custom'. However, when I try to get
> the
> > element directly using getElementById(), it doesn't return the node
> > properly. Am I doing something wrong?
>
> A common problem. See here:
> http://wiki.flux-cms.org/display/BLOG/GetElementById+Pitfalls
>
>
Given the following array:
'bob', "0" => 'briggs', 'whatever', 'whereever');
echo '' . print_r( $myArr, TRUE ) . '';
?>
Array
(
[joe] => bob
[0] => briggs
[1] => whatever
[2] => whereever
)
"joe" and "0" are keys that I created whereas the key "1" and "2" are
keys assigned by PHP when the
> > "joe" and "0" are keys that I created whereas the key "1" and "2" are
> > keys assigned by PHP when the array was created. When iterating
> > through an array, is there a way to determine which were generated by
> > PHP? I can't rely on whether or not the key is an integer because
> > it's qu
Constructors return the object, correct? If so, how can I do this:
class Bob {
private $blah;
_construct( $blah ) {
$this->blah = $blah;
}
public getBlah() {
return $this->blah;
}
}
echo Bob( 'Hello!' )->getBlah();
When I try that, I get the message "Undefined function Bob".
> On Jan 29, 2008 2:37 PM, Paul Scott <[EMAIL PROTECTED]> wrote:
> > Looks like a repurpose of one of my posts:
> >
http://fsiu.uwc.ac.za/index.php?module=blog&action=viewsingle&postid=gen9Srv59Nme5_7092_1182404204
> actually, this is slightly different; here we are talking about being
> able to im
> > eval() is my favorite templating engine.
> > http://php.net/eval
> Ditto on Eval()
> PHP is already a templating system. Why go the long way around?
eval()? Man, you guys have some seriously large cajones. :p
thnx,
Chris
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, vis
> I agree. I usually add a little function like this to my PHP projects:
> function debug( $var )
> {
> echo '';
> print_r( $var );
> echo '';
>
> }
As an aside, you can save lines when debugging by doing:
echo '' . print_r( $var, TRUE ) . '';
thnx,
Chris
--
PHP General Mailing List (ht
> > As an aside, you can save lines when debugging by doing:
> > echo '' . print_r( $var, TRUE ) . '';
> OMG, thanks for that. Lines are so expensive nowadays and all.
Sarcasm aside, when I'm debugging I like to be as concise as possible.
thnx,
Chris
--
PHP General Mailing List (http://www.php
> > when I'm debugging I like to be as concise as possible.
> Concise? Really?
Fair enough. Perhaps I should have said concise with my code, verbose
with my actual messages. :p
thnx,
Chris
Looking for
> http://msdn2.microsoft.com/en-us/library/aa479002.aspx
> I read an Article on the above Microsoft website stating the reason why to
> Migrate from PHP to
> ASP.NET. So can you please justify this proofs from Microsoft and let
> everybody knows if they are
> all TRUE and MEANIFUL atall or they a
> >> should it not use curlies?
> > No, they will be deprecated as of PHP6. (Square brackets used to be, but
> > have been undeprecated and are back in favour!)
> cheers for the heads up on curlies Mike :)
Where can I read more information about this?
thnx,
Chris
--
PHP General Mailing List
> I want to know what is the best solution for handling errors. After reading
> some
> documents dealing with the subject, i have three options:
> * Using a class for error handling
> * Using PEAR error object
> * Using try and catch exceptions
> The error handling i want to implement will be
Let's say I have the following structure:
> > Is that possible? Or is this something I'd have to do programatically
> > using the nodes returned by the XPath query? Basically, I'm just
> > trying to get a fragment of the larger xml document...
> //[EMAIL PROTECTED]'gc3']/child/ancestor-or-self::*
Thanks for the response. However
What is wrong with the following code? It's throwing a DOMException
when I try to set the id attribute for the $lvl1Node but I can't see
why...
$doc = new DOMDocument('1.0', 'UTF-8');
$root = $doc->appendChild( $doc->createElement( 'root' ));
for( $a = 0; $a <= 3; $a++ )
{
$lvl_1_id =
> > You got me.
> Wobbly PHP logo on mine (PHP-5.2.5 debian)
That's all I see for PHP-5.2.1. Should there be something more?
thnx,
Christoph
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
> >> Wobbly PHP logo on mine (PHP-5.2.5 debian)
> > That's all I see for PHP-5.2.1. Should there be something more?
> Probably not, but check the source. :-)
I checked the source. I didn't notice anything unusual...
thnx,
Christoph
--
PHP General Mailing List (http://www.php.net/)
To unsu
Could someone explain to me what I'm doing wrong?
I'm trying to get an element from one DOMDocument and append it to a
different DOMDocument. The (simplified) output of saveXML() from the
first DOMDocument is as follows:
12
Here is a snippet of code:
createElement( 'menu' );
$oRootNode->setAt
> DOM Nodes are specific to the document in which they were created, so
> you can't just append a node from one document into another document.
> The importNode function does what you want.
> http://us2.php.net/manual/en/function.dom-domdocument-importnode.php
Interesting. Why is that, out of
I ran across a PHP function, strip_illegal_chars(), but can't seem to
find anything about it in the documentation. Does anyone know
precisely what it does? Or where I can find actual documentation for
that function?
thnx,
Chris
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe,
Is there a reason why you can't do method chaining off of constructors?
Consider the following class:
class bob
{
public function __construct()
{
echo 'Constructor()';
}
public function one()
{
echo '->one()';
return $this;
}
public function two
> > Why? I thought constructors returned the object?
> It's been a while since I've played with objects in PHP, but couldn't
> you just add the line:
> return $this;
> ...to the end of your __construct() function? Sorry if this is obtuse of
> me to say, I just thought maybe the answer was that sim
> The 'new' keyword has to apply to the object created in the constructor (and
> not the return value of any of the follow-up calls.) To establish this
> precedence, chaining wasn't allowed on constructors.
If precedence was the issue, why doesn't this work, either:
(new bob())->one()->two()
> "Always on the edge of greatness"
"Tripped on his way to the edge of greatness"
thnx,
Christoph
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
> if ($user_name = "Dan Brown") {
> echo "GOING DOWN?!";
> } else {
> echo "Welcome to Heaven";
> }
So I guess that means we're all on the express elevator down. Looks
like it'll get awfully full... :p
thnx,
Chris
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http:
> Anyone know of an unintrusive code beautifier written specifically with in
> mind?
I know it's not quite what you are asking, but the IDE I use has a
really good code beautifier. It works with a great many languages,
not just for PHP. This is on top of a gagillion other really useful
features
I knew that there would be some overhead when working with objects vs
working with arrays, but I didn't expect this much. Is there some
optimization that I could do to improve the performance any? While
the script below is just a benchmark test script, it approximates
functionality that I'm going
* I'm trying to better understand the 'classmap' option for the
SoapClient class. Is it used to define the class of an instantiated
object which will be passed as an argument to the server's function
call? So, as a very simplistic example, it might go something like
this:
sStockSymbol = $sStockS
* I'm not sure if this is a bug (unlikely) or if it's just me (highly
likely). Given the following WSDL,
http://schemas.xmlsoap.org/wsdl/soap/";
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/";
xmlns="http://schemas.xmlsoap.org/wsdl/"; name="TestTesting"
targetNamespace="urn:/test/testing
> different question asked below. So I then add in:
>
> echo 'Types: ' . print_r( $oClient->__getTypes(), TRUE ) . '';
>
> and it turns out that the "data-array" definition in the WSDL is
> getting translated as the following structure:
>
> [XX] => struct data-array {
> any;
> }
>
> Umm, huh? Wh
I'm curious, what utilities do you guys use, if any at all, to map
out/diagram your classes? I'm looking for a decent (I don't really
need a ton of bells and whistles) freeware app but my searches thus
far have proven fruitless.
thnx,
Christoph
--
PHP General Mailing List (http://www.php.net/)
>> A textarea is a simple editor, I am assuming you want something better than
>> that, or you wouldn't have looked further.
> I just tried Demo and got this:
> "Sorry, you must have Internet Explorer 5.5 or higher to use the WYSIWYG
> editor"
> ?!?
Wow. You know people who are still using IE5.5?
>> Curious. Which do you prefer and why?
>> For publicly-declared variables, do you access the attribute directly or
>> use an accessor?
> If it's a public member variable there is no need for plain accessor methods
> - they add no value. I feel the same about private variables with plain get
> and
Is there a way to call a SOAP function and pass the required XML as an
argument instead of an object? I can get this to work:
$oClient = new SoapClient( $sWSDL_URI, array( 'trace' => TRUE,
'exceptions'=> TRUE );
$oArgObj = new ArgObj();
$oArgObj->node1 = 'value'
$oArgObj->node2 = 'value'
$oA
Perhaps I'm misunderstanding what a static method variable is supposed
to do. I thought the value would be static for an class' instance but
it appears it is static across all instances of the class. Consider:
class StaticTest
{
public function __construct()
{
}
public function test( $n
Ok, so why isn't this working as (I, at the very least) expected?
class singleTon
{
private static $thisObj = NULL;
private $thisProp = NULL;
public function __construct()
{
echo 'singleTon::__construct()';
if( !is_null( singleTon::$thisObj ))
{
echo '$thisObj alre
>> Apart from making the constructor
>> private, is there any way I can ensure that there is ever only one
>> instance of an object?
> you could use the magic method __clone.
> For example:
> public function __clone() { trigger_error('The singleton pattern avoids
> cloning this instance', E_USER_ER
>> public function __construct()
> A singleton would usually have a private constructor to prevent
> non-singleton instances.
The problem being if the class in question derives from another class
that has a public constructor... If you are in that particular
situation (which I am), you're basic
> There is absolutely nothing in PHP which prevents you from implementing the
> singleton pattern.
It does if the constructor must be public.
> but your attempt is doomed to failure. What makes you think that a singleton
> class has to inherit from another class?
Nothing at all. Except that in
> Create your singleton class without extending the class you need to extend.
> Create an instance of that class in your object. Implement the __call magic
> method to proxy function calls through to that instance throwing an
> exception (or error) if the method requested doesn't exist. Not particu
> here is in my opinion, what you can do:
> class Base {
> private function __construct()
Except that in one of my follow up posts I indicated that my singleton
class was deriving from a class that had a public constructor.
Thanks anyway. I ended up just using Stut's suggestion. As he said,
it
>> is it possible to overload the class construct(or) ?
>> if yes, how ?
No, it's not.
> class A
> {
>function __construct()
>{
>echo "A";
>}
> }
>
> class B extends A
> {
>function __construct()
>{
>echo "B";
>
96 matches
Mail list logo