[PHP] Exception not being caught

2009-07-15 Thread Weston C
So, I've got a little piece of code designed to play with catching the
exception that's thrown when an object doesn't have a __toString
method.

?php

class A { }

$a = new A();   // Ayn would be proud, right?

try {
echo a is ,$a,\n;
} catch(Exception $e) {
echo \nException Caught: ;
echo $e, $n;
}

?

This does not run as expected. I'd think that when the implicit string
conversion in the try block hits, the exception would be thrown,
caught by the catch block, and relayed.

Instead you don't ever see the words exception caught and you get
Catchable fatal error: Object of class A could not be converted to
string.

If it's catchable, why isn't it caught in my example?

Thanks,

Weston

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



[PHP] Re: table-less layouts; Ideas welcome

2009-05-21 Thread Weston C
On Thu, 2009-05-21 at 09:54 -0400, tedd wrote:
 My thoughts are -- my understanding the reason why tables have
 received such bad-press is that designers have abused tables in
 holding designs together with nested tables AND in doing so made it
 difficult for the visually disabled to pull content from the site.
 Screen readers do not read the screen but rather read the source and
 pull out of it what they (the screen reader program) think is
 content. Translating nested tables becomes an impossible job for them.

I've heard a rumor this is exaggerated, and I buy it to some extent.
Lynx had an algorithm for distinguishing simple tabular data from more
complex (and probably layout) tables back in 1999. I'd assume a
serious screen reader with more development resources behind it could
do better, and I don't think heuristics for working with this would
even be particularly hard.

This isn't to say tangled table markup is never a problem. It is, both
for human and machine readers. But as much as I like CSS -- and as
much as it simplifies many designs -- there are some cases for which
table layouts are easier and/or more robust, so I almost just wish
we'd accepted the horse was out of the barn and tried to figure out an
easy way to signal distinctions between layout tables and semantic
tabular data, rather than trying to get the entire internet to
completely retool.

A few years ago, I started marking my layout tables with
class=layout. Not always a perfect solution, but makes the
distinction easy (and turns out to be a useful styling convention as
well), and if table-based layouts really are a significant obstacle to
machine readers, my guess is something like this would get us over
that hurdle a lot faster than waiting for everyone to give up those
layouts.

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



[PHP] Problems working with HTML using PHP's XML tools (placing mixed text/html into xpath-specified nodes...)

2009-05-21 Thread Weston C
Is there a straightforward way (or, heck, any way) of placing mixed
html/text content into xpath-specified nodes using any of PHP's XML
tools?

So far, I've tried SimpleXML and the DOM and things aren't coming out well.

SimpleXML:

 /* $filename contains path to valid XML file, $xpathxpr contains
valid XPath expression matching at least  one document node, $fillval
contains a mixed well-formed text/xhtml string to be pre-pended within
each matching node */

$sx = simplexml_load_file($filename);
$nodes = $sx-xpath($xpathxpr);
foreach($nodes as $node) {
  $children = $node-children();
  $children[0] = $fillval . $children[0];
}

This only sortof works. I get $fillval appended before the original
contents of each matching docment node but if I've put any markup
in, it's all there as literal text (ie, a
href=http://php.net;php.net/a wouldn't show up as a link, you'd
see the actual markup when the document is rendered).

A variation on this that I tried is creating a new SimpleXMLElement
object, with the mixed text/markup string as an argument passed to the
constructor, since the docs seem to indicate this is blessed. Weirdly,
when I do this, it seems to actually be stripping out the markup and
just giving the text. For example:

$s = new SimpleXMLElement('a href=#Boo/a')
echo $s;

yields Boo (and echo $s-a yields nothing). This would be such a
huge bug I have a hard time believing it, so I have to suspect there's
a dance I'm not doing to make this work correctly.

DOM XML:

 /* again, $filename contains path to valid XML file, $xpathxpr
contains valid XPath expression matching at least  one document node,
$fillval contains a mixed well-formed text/xhtml string to be
pre-pended within each matching node */

$domDoc = new DOMDocument();
$domDoc-loadHTML(file_get_contents($filename));
$search = new DOMXPath($domDoc);
$nodes = $search-query($xpathxpr);
foreach($nodes as $emt) {
$f = $domDoc-createDocumentFragment();
$f-appendXML($fillval . $emt-nodeValue);
$emt-nodeValue = '';
$emt-appendChild($f);
}

This also gets mixed results. It gets cranky and issues warnings about
any HTML entities (despite that it seems it should be clear this is an
HTML document given the invocation of loadHTML), and while I'm seeing
some markup make it through, I'm not in other cases. I haven't quite
figured out the difference.

I can come up with some runnable tests if it will help, but I'm hoping
someone's already familiar with the general issues with using PHP's
XML tools to work with HTML that they can make some good commentary on
the matter.

Thanks,

Weston

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



Re: [PHP] Re: table-less layouts; Ideas welcome

2009-05-21 Thread Weston C
On Thu, May 21, 2009 at 12:10 PM, tedd tedd.sperl...@gmail.com wrote:
 Could you be certain that your algorithm would figure out which way it needs
 to present the text to a blind person?

My own experience browsing the web with Lynx (which for the most part,
tends to ignore table layout, giving you the content of table cells in
source order) suggests that order doesn't end up being a significant
issue. The common layouts tend to read surprising well in source
order. Navigation is usually at the top or the left, so you encounter
it quickly. If there's any problem, most of the time it's that the
page author has done something hideous with a lot of images with no
alt text or abuse of HTML entitites, or part of the navigation
structure is only accessible via javascript or flash or something like
that... all separate issues from repurposing tabular markup.

And when there *is* some kind of a layout issue, most of the time it's
easy to adapt as a human reader by searching/scanning (sometimes
easier than if you're looking at a bad visual layout). The tools that
enhance accessibility on a page in these respects really don't have a
lot to do with whether there's tabular markup -- if you want to enable
easy access to page navigation, you can add semantic information about
that regardless. In fact, that information is quite likely more
important and less prevalent than what you end up with even most
CSS-positioned sites, given that the vast majority of them simply
provide stylesheets for the purposes of... visual layout, and what
you're left with when a screen reader ignores them is linear
source-ordered elements.

None of this is to say that CSS can't be very useful in addressing
this problem (and other problems), or that there aren't some problems
with tabular markup. The presentation example you mentioned is
actually going to be an issue with even real tabular data without some
care taken in the markup. And I don't want to go back to coding 1999
markup for 1999 browsers. Mostly my point is that the problem with
using tables is a bit more limited in size than it's often made out to
be, there are other ways of dealing with the accessibility and
semanticity issues involved, some of them potentially more effective.
And for some cases, table layouts just work better. I think we'd be
better off with a wide variety of professionals who can balance these
different issues than with a  tables considered harmful summary.

 Now compound that with cells holding images,
 place-holders, empty cells and cells with navigation elements,
 flash, videos, and such -- and you might have a better appreciation
 as to the problem screen readers face.

These are actually some of the heuristic markers I believe some
browsers actually use (and if they don't, they certainly could). If
you have a table whose cells largely contain highly mixed markup,
largely presentational elements, no alternative data, chances are
pretty good that it isn't tabular data. And...

Benjamin Hawkes-Lewis bhawkesle...@googlemail.com
 WCAG 1.0 ... explained how /authors/ could distinguish between layout
 tables and data tables:

 1) When writing a presentational table, stick to the elements table, tr,
 td. Do not use the headers, scope, axis, or summary attributes.
 Make sure layout tables make sense when linearized.

 2) When writing a data table, add the elements th, thead, tbody,
 tfoot, caption, and col and the attributes headers, scope, axis,
 and summary wherever appropriate.

Exactly. These are great markers for distinguishing between where
authors were using table markup semantically or presentationally. I
think in practice there are probably many others available.

 Fast forward a decade, and authors are getting another tool in our toolbox,
 not a million miles away from your 'class=layout'. I don't think it's very
 well specified yet, but:

 http://www.w3.org/TR/wai-aria/#presentation

I'm actually amazed... this is very nearly what I proposed in some
discussions back in 2004. I eventually shifted to class=layout
because it had some other practical benefits and everybody I talked to
seemed to feel cluttering up the attribute space with yet another item
was wrong (on top of this sortof general malaise about repurposed
table markup), especially when considering how much semantic mileage
you can get out of class attributes. I'd be totally happy to see
anything like it adopted, though, and as I said before, think it'd
push the semantic web forward faster than waiting for everyone to come
around to doing things one blessed way.

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



[PHP] make install doesn't seem to work on downgrade on OS X -- anyone else seen this?

2008-08-19 Thread Weston C
I recently downgraded from a build of 5.3 to 5.2.6 on OS X, and had a
bit of time figuring out what was going on when make install didn't
seem to actually copy the CLI binary and Apache SO to their target
spots.

Has anyone else seen this problem?

What category would a bug report for this be under? It's a
build/install issue, but there's no particular category for these
beyond compile issues...

Thanks,

Weston

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



Re: [PHP] make install doesn't seem to work on downgrade on OS X -- anyone else seen this?

2008-08-19 Thread Weston C
On Tue, Aug 19, 2008 at 9:43 AM, Jason Pruim [EMAIL PROTECTED] wrote:
 Is there a particular reason you are downgrading?

I'm pretty happy with some of the features in 5.3, but have been asked
to work with a codebase that turned out to have some issues under 5.3
that didn't show up under 5.2.x. I'd love to have the time to dig and
give feedback on the issues for the improvement and quicker release of
5.3, but unfortunately work has to be a higher priority. :(

-W

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



[PHP] PHP 5 auto-htmlentitizing strings?

2008-08-02 Thread Weston C
I just switched over an app from PHP 4 to PHP 5, and one of the weird
things I'm noticing initially is that some of the html output seems to
be html entitized. For example, a link that was showing up in html
output as:

 a href=http://metaphilm.com/philm.php?id=29_0_2_0;Is Tyler Durden
Hobbes?/a

now gets transformed to:

lt;a href=http://metaphilm.com/philm.php?id=29_0_2_0gt;Is Tyler
Durden Hobbeslt;/agt;

No other changes in the PHP source -- just a change in the interpreter.

Any idea what could be causing this?

Thanks,

Weston

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



[PHP] 5.3 Timeline and Features(true anon functions? shorter array syntax?)

2008-06-21 Thread Weston C
Just curious if anyone knows the rough timeline for PHP 5.3.

Also curious if anyone knows whether anon functions/closures or a
shorter JSON-ish array syntax are being considered for inclusion. I
know there were two patches announced in December/January:

http://marc.info/?l=php-internalsm=119833623532713w=2
http://marc.info/?l=php-internalsm=119995972028293w=2

But they don't seem to be part of the early June 5.3 releases, much as
I'd love to see them.

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



[PHP] PHP Extensions as Shared Objects?

2008-05-29 Thread Weston C
This might be a dumb question with an obvious answer somewhere,  but
I'm wondering if it's possible to build php extensions as shared
objects that plug into the PHP binary much like an apache shared
module plugs into apache.

Is PECL close to this?

Sorry if this is obvious. Searches on the topic are pretty noisy given
that php's installation as a shared module itself for Apache are a
fairly popular topic.

Thanks,

Weston

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



Re: [PHP] PHP Extensions as Shared Objects?

2008-05-29 Thread Weston C
On Thu, May 29, 2008 at 7:11 PM, Chris [EMAIL PROTECTED] wrote:
 See http://www.php.net/dl (though a lot of hosts disable this
 functionality for security reasons).

Fortunately, I'll have full control of the hosting environment in the
context this matters. :)

dl is  definitely interesting, but I'm worried that runtime invocation
might mean performance hits. Is there a way to do load/startup time
inclusion?

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



[PHP] Advantages of declared vs undeclared object properties

2008-05-25 Thread Weston C
In a setup like you've got with a SimpleXML object, where object
properties aren't necessarily declared in the class definition but are
added on an ad hoc basis, is there any performance hit?

If not, other than the ability to mark properties as private, is there
any other particular advantage to declaring them at the top of the
class definition?

Thanks,

Weston

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



[PHP] Ways to tell if existing setup is SAPI or Shared Object?

2007-04-19 Thread Weston C

What ways are there to tell if PHP is actually built into an Apache 2
installation or if it's installed as a shared object?

I've dropped a file containing phpinfo() on the server I'm looking at,
hoping the Server API value would give me a clue, but it just says
Apache 2.0 Filter, and I don't know if Apache filters are required
to be one or the other

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



Re: [PHP] Ways to tell if existing setup is SAPI or Shared Object?

2007-04-19 Thread Weston C

On 4/19/07, Richard Lynch [EMAIL PROTECTED] wrote:

On Thu, April 19, 2007 4:08 pm, Weston C wrote:
 What ways are there to tell if PHP is actually built into an Apache 2
 installation or if it's installed as a shared object?

 phpinfo() / Server API value .. just says Apache 2.0 Filter

If you can read httpd.conf, and find a LoadModule there with php, then
it's shared, I think.


I do have access to httpd.conf. I can't find a LoadModule directive
for php in it, though. Is that a bad sign? Could they possibly have
been stuffed into any of the other lesser-used conf files?


The php_sapi_name function and PHP_SAPI constant may be of use if you
just want SAPI info in your program, rather than all of phpinfo()

They're probably all exactly the same output, though.


Seems to give the same result.


... if you compiled it directly into Apache (does anybody do
that anymore?)


I certainly wouldn't. But I think this is the default Apache2
distribution on RH9, and you just never know with those folks. ;)

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



Re: [PHP] Ways to tell if existing setup is SAPI or Shared Object?

2007-04-19 Thread Weston C

On 4/19/07, Edward Vermillion [EMAIL PROTECTED] wrote:


Fedora, and I'm assuming RedHat and possibly others that use their
system layout, will put the loading line in /etc/httpd/conf.d/
php.conf so yes it can be in an external configuration file.


That's the exact location, and it's a shared object. Thank you!

The other method I thought of was to search for lib4php.so, and if
it's found, rename it, restart Apache, and see if/where it complains.
:)

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



[PHP] Trouble compiling in mysqli under PHP5 -- mysql_config not found

2007-01-02 Thread Weston C

I'm trying to build a CLI/CGI binary of PHP5 with MySQLi under Mac OS
X. When I invoke configure, I get the following error message:

checking whether to enable embedded MySQLi support... no
mysql_config not found
configure: error: Please reinstall the mysql distribution

Now, mysql (4.1.22) is in fact installed, and it looks to me like the
headers are in fact there (and mysql_config seems to be under ./bin),
and I did give it the path with the config option
(--with-mysqli=/usr/local/mysql -- yes, I know this isn't the
conventional Mac OS X path, but I like these things under /usr/local,
so).

Curiously, I note that a build using --with-mysql=/usr/local/mysql
works just fine.

Any ideas what I'm doing wrong here?

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