[PHP] php obj -> xml ?
Just wanted some opinions on the best way to produce well-formed xml from a php object. In my case, I was toying with the idea of a generic way to product an xml file from a PEAR DataObject - the idea being that a 3rd party requests data, I extract from mysql using Pear's DataObjects, then tell that objects to produce xml (or pass it to a transformer or something). Links? Ideas? Recommendations from RL experience? cheers, neko -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: getting database connection to fail gracefully
Andy Clarke wrote: Is there a way to get a database query to fail gracefully, so that rather than calling Die(), it can work around the problem? In other words, to do something like: Another option is to make use of PEAR's DB support in your code, rather than using the mysql_ functions directly. This will provide a much better framework for database connectivity/use in general. http://pear.php.net - check out the manual. neko -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Default argument values
Hey All, I've been trying to write a function that accepts multiple optional parameters, some of which are ints. The function signature looks like this: function blahBlah($fromDate, $toDate = 0, $limit = 20, $limitNodeType = null) I've been reading up here: http://www.php.net/manual/en/functions.arguments.php But it doesn't describe what to do with multiple optional arguments. Can I call the function like this: blahBlah($date, null, null, $limitNodeType); ? Need some help getting this language feature sorted. cheers, neko -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Failed to initialize session module
got it, had to change session.save_handler = files ;session.save_handler = user to files - my bad! neko -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: smarty vs. patTemplate vs. includes - newbie q
A great article on PHP and template engines can be found here: http://phppatterns.com/index.php/article/articleview/4/1/1/ The opinon of the author is that template engines might not be worth your time, and I'm inclined to agree. I'd rather develop a more comprehensive CMF which limits what the user can design in other ways, rather than use some template engine like smarty or velocity. To me, templates just seem like a dumbed-down language - not that useful in my opinion. neko -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] emailing a web-page
Hi guys, I want to automate the process of connecting to a web-page and sending it as a HTML email (like a weekly newsletter in html). I've been reading up a bit on PEAR's Mail_mime (http://pear.php.net/manual/en/core.mail.mime.php) but I just wanted to know what the fastest way to accomplish my requirement is from your collective experience? thanks, neko -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] emailing a web-page
> is it a webpage you create with php or is it a webpage that you get from > just any site? It's a dynamically generated page on my site - I wanted to just include the url's contents into a string, or something. So no I can't cheat and just grab from the filesystem :) cheers, neko -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: emailing a web-page
update: I think I just need to work out how to grab a web-page and include it into a string to supply to the mail I'm generating (using pear). Provided that the hyperlinks aren't relative I should have a funky looking email going on.. neko "Neko" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi guys, > > I want to automate the process of connecting to a web-page and sending it as > a HTML email (like a weekly newsletter in html). > > I've been reading up a bit on PEAR's Mail_mime > (http://pear.php.net/manual/en/core.mail.mime.php) but I just wanted to know > what the fastest way to accomplish my requirement is from your collective > experience? > > thanks, > neko > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: emailing a web-page
http://www.php.net/manual/en/function.file-get-contents.php I was thinking of using this, however the website I want to pull the HTML from uses relative links, so that places me in a pretty pickle if I want to have the email make use of stylesheets and images. :) neko_ "Arjan Gijsberts" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > That shouldn't be a problem. You could use fopen() to open the file. > > "Neko" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > update: > > > > I think I just need to work out how to grab a web-page and include it into > a > > string to supply to the mail I'm generating (using pear). Provided that > the > > hyperlinks aren't relative I should have a funky looking email going on.. > > > > neko > > > > "Neko" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > Hi guys, > > > > > > I want to automate the process of connecting to a web-page and sending > it > > as > > > a HTML email (like a weekly newsletter in html). > > > > > > I've been reading up a bit on PEAR's Mail_mime > > > (http://pear.php.net/manual/en/core.mail.mime.php) but I just wanted to > > know > > > what the fastest way to accomplish my requirement is from your > collective > > > experience? > > > > > > thanks, > > > neko > > > > > > > > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: emailing a web-page
Question : When people send you junk e-mails they often have image refs and so forth - does that mean they are using absolute links in the img refs? I need to find a way to allow a non-technical user to quickly and easily send off a web-page (generated on the fly) in email format, but so far I'm still working out the particulars of sending as HTML with additional resources (images, stylesheets). neko_ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: emailing a web-page
> 4) Easy to do for anyone, even for you, it's simple. Thanks for that sly jab ;) neko_ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] what are the planned features of php 5?
I read something a while back about more OO features, but I was wondering if there is a roadmap anywhere? cheers, neko -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] quick check - by ref vs by value with objects
Hi guys, If I have an object that has another object as a variable (eg, a dbConn object), then I create another object and pass this dbConn in the constructor, if that second class sets that arg to it's own variable, is it true in 4.3.1 that they will NOT be sharing the same object reference? I this I think is different in the zend 2.0 engine - see here: http://www.zend.com/images/press/Feb_2003-4_Zeev_PHP5.pdf But anyway, if I want each of the 2 classes to each point to the same dbConn object, does that mean I have to write the constructor as function secondClass(&$dbConn) { $this->db = $dbConn; } ? cheers, neko -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] eval help
Hi guys, My current task involves passing a string into a function that is able to reference variables defined within that function for the final output. The idea is that a function iterates through objects and eval's the string so that the objects data (name etc) is substituted in the string. Currently I have something like this: $someVar = "testing for node - wootah, \$evalTestArr[TAG_PAGENAME]" then in some other function that gets passed this string ... $evalTestArr[TAG_PAGENAME] = "hello anna marie gooberfish!"; $str = $someVar; eval("\$str=\"$str\";"); if I echo it out, the substitution is not done. any thoughts? I'm reading through http://www.php.net/manual/en/function.eval.php but yet to be inspired. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: eval help
note that the following php: Hello, $name"; $str2 = "Hello, $arr[0]"; $str3 = "Hello, $arr2['name']"; eval ("\$evaldString = \"$str\";"); echo $evaldString; eval ("\$evaldString = \"$str2\";"); echo $evaldString; eval ("\$evaldString = \"$str3\";"); echo $evaldString; ?> produces: Broness!Hello, ScottHello, DudeHello, -- note that the last cannot be seen - I'm sure I'm almost there, but I have to be able to reference an associative array. Scott -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: eval help
Thanks Dan - I just worked this out before reading your solution! :) $str4 = "Hello, ".$arr2['name']; cheers and thanks to all - lets see how that goes within my framework now :) neko -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: eval help
Actually, I just realised that what I want to accomplish is different from my example - the main issue is with scope: we're in the pipe, 5-5-5."); $str = "Hello, \$name"; $str2 = "Hello, \$arr[0]"; $str3 = "Hello, \$arr2['name']"; echo doEvalWithVarsInScope($str); echo doEvalWithVarsInScope($str2); echo doEvalWithVarsInScope($str3); } function doEvalWithVarsInScope($str) { echo("trying to eval for str=$str"); $name = "Scott"; $arr[] = "Dude"; $arr2["name"] = "Broness!"; eval ("\$evaldString = \"$str\";"); return $evaldString; } ?> -- will produce: we're in the pipe, 5-5-5. trying to eval for str= Hello, $name Hello, Scott trying to eval for str= Hello, $arr[0] Hello, Dude trying to eval for str= Hello, $arr2['name'] Hello, -- any (more) help is greatly appreciated. cheers, neko -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: eval help
we're in the pipe, 5-5-5."); $str = "Hello, \$name"; $str2 = "Hello, \$arr[0]"; $str3 = "Hello, \$arr2[".NAME_TAG."]"; echo doEvalWithVarsInScope($str); echo doEvalWithVarsInScope($str2); echo doEvalWithVarsInScope($str3); } function doEvalWithVarsInScope($str) { echo("trying to eval for str=$str and NAME_TAG:".NAME_TAG); $name = "Scott"; $arr[] = "Dude"; $arr2[NAME_TAG] = "Broness!"; eval ("\$evaldString = \"$str\";"); return $evaldString; } ?> -- produces: we're in the pipe, 5-5-5. trying to eval for str= Hello, $name and NAME_TAG:name Hello, Scott trying to eval for str= Hello, $arr[0] and NAME_TAG:name Hello, Dude trying to eval for str= Hello, $arr2[name] and NAME_TAG:name Hello, Broness! -- done, but it's uglier than I was hoping :( -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: eval help
ok - my latest in the eval saga is this: I want to be able to eval a function call anywhere in the string supplied, and the function call is not in scope when the string is defined. So -- somewhere in my code I wanted something like this: $string = "testing nodename: \$node->getName() pagename:\$nodePageTags[".TAG_PAGENAME."]"; -- where the code is evaled eventually, there is a $node object defined, so the function call should work. Of course, that currently does not work :) cheers, neko -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] eval challenge
- define a string that has a function call in it (that returns a string) that at the time of declaration is not in scope, eg $str = "this is the name : \$node->getName()"; // $node is _not_ defined currently, so we can't escape out then, later on in the code, this string will be passed to a function that has $node in scope, and that's when I want to eval the string to replace the value. $node = new Node($argwhatever); eval("\$str=\"$str\";"); // $node is now in scope, so I'd really like $node->getName to return something meaningful Anyone able to solve this one? Yesterday I could achieve most other requirements with eval, but this one has me stumped. cheers, neko -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] eval challenge
Thanks for your time, Dan. Currently, I'm using defined tags for replacing info from my CMS, eg: $str = "" Then I have a function that has all the objects in scope, and can perform the necessary replacements. I am prototyping some stuff with smarty, but so far have yet to see how it benefits over my current implementation. I don't have to to worry about non-technical persons building/maintaining the site, so I'd rather stick with include() to build my pages from templates/blocks/content. As I learn more about smarty, I might use it to power the presentation layer of my CMS, but only when I can see a long-term benefit from using it. My cms makes use of presentation logic components, which you supply microtemplates to in order to produce the final output. These components can reside within "templates", so currently my html redundancy is minimal. cheers, neko -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] eval challenge
> ok ... what would represent? > The output of $ofa-core->siteMapLink();? > > If your using XML throughout - have you looked at XSLT transformations? It's just a symbolic name - the output is created from a few different objects within the CMS, but it was such a commonly used set of data requests that I make a tag up to handle them all at once, to make it a bit cleaner. XSL/XSLT is on my "to prototype" list ;) neko -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP OOP design question
Answer - use PEAR for both your database connection and as a data modeling layer: http://pear.php.net check the documentation for more info. neko "Joseph Szobody" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] I have several web projects that are all database driven. I have recently been diving into OOP, and rewriting a lot of procedural code in OOP. I have a design question about handling the MySQL connection. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] reversing attribute in array of objects
I have a bit of a good one for you guys: I have an array of objects which have an attribute $level (I use $obj->get/setLevel() to access it). Now, this array consists of these objects with $level in descending order, and the same $level int can be set to multiple objects (in order), eg: $objArr[0]->level = 5 $objArr[1]->level = 5 $objArr[2]->level = 4 $objArr[3]->level = 3 $objArr[4]->level = 2 $objArr[5]->level = 2 $objArr[6]->level = 2 $objArr[7]->level = 1 what I want to do is to reverse the $level attribute for the objects (not the objects themselves!!!) in the array by using the $level attribute, so in this case I'd end up with: $objArr[0]->level = 1 $objArr[1]->level = 2 $objArr[2]->level = 2 $objArr[3]->level = 2 $objArr[4]->level = 3 $objArr[5]->level = 4 $objArr[6]->level = 5 $objArr[7]->level = 5 Any tips on this one? -- cheers, neko -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php web indexer?
Hi guys, I'm looking for a PHP/MySQL based http site indexer - I won't want to do filesystem searches, I want to do something like a standard web search engine (like google) performs for my site. I was hoping to make use of an existing search engine (open source) rather than write a custom search module for my site. I was looking at products like: lucene (java I know, and text based indexer) http://jakarta.apache.org/lucene/docs/index.html htdig - looks interesting, but no windows distribution except through cygwin (I think) http://www.htdig.org/ PhpDig - lots of french scattered about, couldn't get it to work properly (suspect doesn't run on php 4.3.x) http://phpdig.toiletoine.net/ At the moment, I'm leaning towards just doing an on-the-fly fulltext search in mysql of my content field in my CMS, but I was keen to see if I could find a generic http indexer for better results more quickly. cheers, neko -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php web indexer?
If anyone's interested, I integrated phpdig into my site. Seems to work quite well, and only took me a few hours to integrate it with the site's framework. nice! neko -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] tips on sorting an array of objects by an attribute?
Hi Guys, Just after some experience... What's the best way to sort an array of objects by one of their attributes, accessed by $obj->getFoo() (its a number) ? I was thinking a bubble-sort, making multiple passses and switching array elements until there are no more switches to make. Any tips? The array size is not very large (not will it ever be), so it's doesn't have to be a super-lean sorting algorithm (no harm though ;) ) cheers, neko -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Web Service in PHP/XML
And if you can't be arsed with SOAP, try XML-RPC, which does the job for me. Check PEAR for an implementation, or try Keith Deven's library, which is easy to use (you only deal with PHP types, and leave the XML to the library) http://keithdevens.com/software/xmlrpc/ -neko -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] resolving php tags in a string
I have a question: I normally use include to include a file, which often has php tags that are then interpreted and resolved. However, in one case I am reading a text file into a string (fread), then running nl2br() on it to present it (with an echo command). However, I wish to also resolve any php tags, which obviously aren't in this case and are just presented in the browser as plain text. What's the best way to solve this one? First thought was to write it to a temporary file and then call an include on that, but that sounds plain bad. neko -- "The secret of genius is to carry the spirit of the child into old age, which means never losing your enthusiasm." -- Aldous Leonard Huxley -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Connection handling and output_buffering
Hi guys, Was reading through: http://uk.php.net/manual/en/features.connection-handling.php And I was wondering how PHP handles script termination when you have 'output_buffering = On' in your php.ini? If I have a long script that does lots of database stuff for example, and is riddled with echo() function calls, how will php handle a user clicking stop in their browser half way through? I'm guessing that it WILL continue execution to the end, then when you send the buffer back to the client it determines that the client stopped the request and it terminates. I guess some simple testing will suffice! Neko -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] building CLI version only
Hey guys, A server I'm using has PHP compiled into Apache, and I want to leave that alone and just build a CLI version of php. Can I get away with just going: ./configure --with-mysql --prefix=/some/home/dir make make install ? I dont' want to upset the existing apache installation of PHP or anything, just want a CLI exe in my home dir to do some stuff with. thanks, neko -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php