php-general Digest 1 Dec 2006 10:31:53 -0000 Issue 4490
Topics (messages 245380 through 245396):
Re: Preg_match - Find URL and convert to lower case
245380 by: Dave Goodchild
245381 by: Kevin Murphy
245388 by: Jonesy
245389 by: Dave Goodchild
Re: Webbased Visual DOM Training Tool
245382 by: Bernhard Zwischenbrugger
Re: SOLVED: [PHP] Preg_match - Find URL and convert to lower case
245383 by: Kevin Murphy
Re: Tidy HTML source?
245384 by: Paul Novitski
245392 by: Satyam
245396 by: Sancar Saran
EZ array problem - What's wrong with my brain?
245385 by: Brian Dunning
245393 by: Youri LACAN-BARTLEY
Re: [PHP 4.4.5 / Apache 2.2.3] Abrupt and unrepeatable Segmentation fault (11)
245386 by: Chris
245390 by: Jan Schröter
Re: problem with register globals on new server
245387 by: Chris
mssql conflict with sybase...
245391 by: Le Phuoc Canh
Re: Help with strange include problem in PHP 5.2.0
245394 by: Markus Mayer
245395 by: Markus Mayer
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
Why not use strtolower on the string after the replacements have been made?
--
http://www.web-buddha.co.uk
--- End Message ---
--- Begin Message ---
Well the problem would be then that the entire string would be lower
case, and I only can have the link as lower case. Is there a way to
apply strtolower into the preg_match?
--
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada Community College
www.wncc.edu
775-445-3326
On Nov 30, 2006, at 2:26 PM, Dave Goodchild wrote:
Why not use strtolower on the string after the replacements have
been made?
--
http://www.web-buddha.co.uk
--- End Message ---
--- Begin Message ---
On Thu, 30 Nov 2006 14:16:16 -0800, Kevin Murphy wrote:
>
> I have some text that comes out of a database all in uppercase (old
> IBM Mainframe that only supports uppercase characters).
I see via other followups that you have your kludge working. *But* ,
What do you mean by "old IBM Mainframe that only supports uppercase
characters"? The EBCDIC codes X'81' > X'89' (a-i), X'91' > X'99' (j-r),
and X'A2' > X'A9' (s-z) have been defined and used since probably before
you were born. I have in front of me my first IBM Green Card (IBM
System/360 Reference Data, GX20-1703-3) from 1966 which debunks that
urban legend.
If the data in the mainframe database is all upper case, it was sloppy
programming or sloppy design that got it there. If it _is_ stored in
the mainframe database in proper UC/lc form, then it is probably a
sloppy extraction procedure that is to blame for your input.
Jonesy
--
Marvin L Jones | jonz | W3DHJ | linux
38.24N 104.55W | @ config.com | Jonesy | OS/2
*** Killfiling google posts: <http//jonz.net/ng.htm>
--- End Message ---
--- Begin Message ---
In that case you could use the /e trailing option to use strtolower on the
subpattern.
--- End Message ---
--- Begin Message ---
Hi
> >
> > http://test.datenkueche.com (you need Firefox !!!)
>
> I found it annoying that I couldn't break out of "demo1" by clicking
> on "demo2"
I have so many "setTimout" in javascript... but good point, I will
change that. Reload the page can be a workaround for now.
>
> demo1 demo2 demo3 should probably change cursor or something to appear
> more "clickable"
done.
>
> I didn't really understand what I was looking at, or why I'd want it
> or what I was supposed to learn from it...
>
It's for learning DOM. There are the same commands in Javascript and PHP
(diffent syntax "." instand of "->").
It's very usefull for AJAX, Webservices,...
To start, here is a simple example:
http://www.khtml.org/guestbook/
http://www.khtml.org/guestbook/index.phps
(a guestbook)
> It looked very slick, but had an awful lot of repition of filling in
> some DOM field and clicking "do it".
That's DOM. There are only low level functions. The good thing is, that
you can do really a lot if you know about 10 DOM Methods. And the
methods are the same in Javascript !!!
>
> I don't really need to see that more than a couple times to know I can
> fill in those fields and click "do it".
>
> What I *do* need to know is what they heck to put in those boxes...
> bodylist
> listbody
> bodyList
> listBody
> I have no idea which of the above 4, if any, is the "right thing" to
> put in the box, and doubt that I'd figure it out any time soon...
bodylist, body, divElement,... are variable names. You can fill in what
you want. The "variables" are Objects. If you click on a variable (on
the right side) the object will be highlighted in the Tree.
"body" and "div" are tagNames - the names of HTML Elements.
Everything with a $ is a variable.
>
> > There are also some "special" training files. The time you need to
> > finish an exercise will be stored in a "hi score" list.
>
> I'm not sure I even figured out how to START an exercise, much less
> finish it...
choose "guestbook2", "guestbook3"
>
> Maybe I'm just the village idiot, but I needed a bit more instruction
> on what the heck I was supposed to be doing... Or maybe that's
> covered in a classroom somewhere.
If you never did something with DOM, this tool is not really useable
without more instructions. Maybe I will add a documentation.
At the moment the starting point for learning is:
http://www.php.net/dom
The first thing you need to know is what an "element", "attribute" and
"textNode" is.
Simple_xml maybe is a little bit simpler then DOM, but DOM you can also
use in Javascript, Java, Python, Perl,... for HTML, SVG, MathML,...
Together with XSLT it is really powerfull.
>
> It was definitely very slick though, whatever it was.
>
Thank you. And thank you for testing and your comment!!!
Bernhard
--- End Message ---
--- Begin Message ---
$section_notes = preg_replace('/WWW.(.*?) /e', '"<a href=\"http://
www." . strtolower("$1") . "\" target=\"_blank\">http://www." .
strtolower("$1") . "</a>"', $section_notes);
For some reason I can't get it to work if I decare those items as
variables. They have to be inside the preg_replace as written. But,
it works now. Thanks for the help.
--
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada Community College
www.wncc.edu
775-445-3326
On Nov 30, 2006, at 3:04 PM, Kevin Murphy wrote:
Well the problem would be then that the entire string would be
lower case, and I only can have the link as lower case. Is there a
way to apply strtolower into the preg_match?
--
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada Community College
www.wncc.edu
775-445-3326
On Nov 30, 2006, at 2:26 PM, Dave Goodchild wrote:
Why not use strtolower on the string after the replacements have
been made?
--
http://www.web-buddha.co.uk
--- End Message ---
--- Begin Message ---
On Thursday 30 November 2006 18:51, Paul Novitski wrote:
> With respect to separating code and markup, you said "sometimes there
> are reasons not to do so, for example, web services." What are some
> of those reasons?
At 11/30/2006 10:57 AM, Sancar Saran wrote:
What about performance ?
Web services tend to be quite small applications, but even for larger
ones I've never found performance to be an issue. Servers are fast
and built for this kind of work: opening and reading files, running
software. They have fast chips and big RAM. Regardless of which
technique you use, you're going to utilize server resources and get
your results in however many milliseconds.
A templating system requires the processor to merge content with
template. An inline markup assembly system requires the processor to
build the markup from function calls. Where is the technique that
doesn't take machine cycles?
What about compexity ?
I separate logic from markup in order to reduce complexity. I find
both PHP logic and HTML markup easier to write, read, proofread, and
modify when they're separate from one another (I use the word 'clean').
Those SO nice seperated template system produces lots of mini TPL files.
I'm not talking about "those template systems," whichever ones you're
referring to, I'm talking about programming style and practice. I
don't use any templating system you've ever seen. I roll my own
code. I can make my templates as few or many as the project deserves.
You only need to produce as many template files as you need and
want. Separation of markup from logic doesn't necessarily mean
separate files: when I'm doing somethign quick & dirty I'll include
the markup in the PHP file as a heredoc. What's most helpful to me
is to remove the markup tags and attributes from the PHP logic
structures as much as possible.
I haven't seen any templating system out there in the world that I
like, mostly because they mix the markup & logic too much for my
taste or because they don't let me design the markup precisely the way I want.
You have to include them...
Includes are easy. Actually I usually use file_get_contents() in a
function that selects accompanying CSS & template files programmatically.
You have to parse them.
Not necessarily. But if you do need to parse them, you need to write
the parsing engine only once.
Also you have to track and manage them.
Yes, as you must manage all the files that make up a project. Adding
a few more isn't a burden, especially if they bring clarity and
efficiency to the work.
And I'm not sure those template system gives you freedom. Because you cannot
change your site design with this tpl files. If you change them too much you
have to change your php code.
I beg to differ: you *can* change your site design if you're using
templates. That's part of the purpose of layer separation and
templating in the first place, to enable markup changes without
necessarily requiring software changes. You're free to change the
template and/or change the stylesheet and/or change the data source
according to your needs.
Although we talk of separating logic from markup from presentation,
these are not absolutely clean separations -- each component must
have hooks in the others, otherwise there's no basis for a
merge! Therefore if you change one component greatly enough, at
least one other component must change as well. This is true of HTML
and CSS, it's true of HTML and JavaScript, it's true of HTML and
PHP. It's true of any interactive components in any system. It's
true of PHP itself -- if you change a function's arguments or return
type or a class's methods, you'll have to change the parts of your
code that call that function or invoke that class. That's just the
way it is. I'm sure you wouldn't argue that we write our software as
one long mainline stream just to avoid includes and function
calls. But it sounds as though you're suggesting that logic & markup
should be combined in the same statements simply because you don't
want to have to change more than one component.
Really good website designs can make modification less
onerous. Layer separation is one of those techniques.
Fortunately there are many ways to accomplish similar goals. I'm not
claiming that my own programming preferences are the best, only that
they work the best for me. It's good that we take different paths --
that's how evolution happens. What I'm asking for are the rationales
so I can see if Satyam's methodology could work for me. I agree that
his pre-processed PHP looks very clean. If I thought markup should
be constructed incrementally with program logic I'd be tempted to use it.
...
And my point of view. Using <html tag <?php echo value ?> > <?php echo
value ?></htmltag> days are over...
I agree completely! I hate that messy crap that results from mixing
markup with PHP.
Sancar, you seem to have had some very negative experiences with
templating systems that were either hard to understand or poorly
designed. I sympathise with you, but you may have let your
disappointment cloud your perceptions on this subject. It isn't
necessary to throw out the concept of separation of markup from logic
just because many attempts to implement it have failed.
I'll be very interested to see where Satyam's pre-processor work
leads. It's possible, if not probable, that someday I'll be
convinced that inline markup assembly is as desirable as, say, inline
SQL processing.
Warm regards,
Paul
--- End Message ---
--- Begin Message ---
This is getting too philosophical for my taste. There are many reasons to
justify different ways of programming and each user, according to his/her
requirements, experience and circumstances weights them differently and may
decide in a different way. I am not about argue in favor of any one method.
I just developed a program that might help one of those particular methods,
which anyone is free to choose or not to. If you find it useful, I am happy
to help, if you don't, that is fine with me.
Satyam
----- Original Message -----
From: "Paul Novitski" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Friday, December 01, 2006 1:47 AM
Subject: Re: [PHP] Tidy HTML source?
On Thursday 30 November 2006 18:51, Paul Novitski wrote:
> With respect to separating code and markup, you said "sometimes there
> are reasons not to do so, for example, web services." What are some
> of those reasons?
At 11/30/2006 10:57 AM, Sancar Saran wrote:
What about performance ?
Web services tend to be quite small applications, but even for larger ones
I've never found performance to be an issue. Servers are fast and built
for this kind of work: opening and reading files, running software. They
have fast chips and big RAM. Regardless of which technique you use,
you're going to utilize server resources and get your results in however
many milliseconds.
A templating system requires the processor to merge content with template.
An inline markup assembly system requires the processor to build the
markup from function calls. Where is the technique that doesn't take
machine cycles?
What about compexity ?
I separate logic from markup in order to reduce complexity. I find both
PHP logic and HTML markup easier to write, read, proofread, and modify
when they're separate from one another (I use the word 'clean').
Those SO nice seperated template system produces lots of mini TPL files.
I'm not talking about "those template systems," whichever ones you're
referring to, I'm talking about programming style and practice. I don't
use any templating system you've ever seen. I roll my own code. I can
make my templates as few or many as the project deserves.
You only need to produce as many template files as you need and want.
Separation of markup from logic doesn't necessarily mean separate files:
when I'm doing somethign quick & dirty I'll include the markup in the PHP
file as a heredoc. What's most helpful to me is to remove the markup tags
and attributes from the PHP logic structures as much as possible.
I haven't seen any templating system out there in the world that I like,
mostly because they mix the markup & logic too much for my taste or
because they don't let me design the markup precisely the way I want.
You have to include them...
Includes are easy. Actually I usually use file_get_contents() in a
function that selects accompanying CSS & template files programmatically.
You have to parse them.
Not necessarily. But if you do need to parse them, you need to write the
parsing engine only once.
Also you have to track and manage them.
Yes, as you must manage all the files that make up a project. Adding a
few more isn't a burden, especially if they bring clarity and efficiency
to the work.
And I'm not sure those template system gives you freedom. Because you
cannot
change your site design with this tpl files. If you change them too much
you
have to change your php code.
I beg to differ: you *can* change your site design if you're using
templates. That's part of the purpose of layer separation and templating
in the first place, to enable markup changes without necessarily requiring
software changes. You're free to change the template and/or change the
stylesheet and/or change the data source according to your needs.
Although we talk of separating logic from markup from presentation, these
are not absolutely clean separations -- each component must have hooks in
the others, otherwise there's no basis for a merge! Therefore if you
change one component greatly enough, at least one other component must
change as well. This is true of HTML and CSS, it's true of HTML and
JavaScript, it's true of HTML and PHP. It's true of any interactive
components in any system. It's true of PHP itself -- if you change a
function's arguments or return type or a class's methods, you'll have to
change the parts of your code that call that function or invoke that
class. That's just the way it is. I'm sure you wouldn't argue that we
write our software as one long mainline stream just to avoid includes and
function calls. But it sounds as though you're suggesting that logic &
markup should be combined in the same statements simply because you don't
want to have to change more than one component.
Really good website designs can make modification less onerous. Layer
separation is one of those techniques.
Fortunately there are many ways to accomplish similar goals. I'm not
claiming that my own programming preferences are the best, only that they
work the best for me. It's good that we take different paths --
that's how evolution happens. What I'm asking for are the rationales so I
can see if Satyam's methodology could work for me. I agree that his
pre-processed PHP looks very clean. If I thought markup should be
constructed incrementally with program logic I'd be tempted to use it.
...
And my point of view. Using <html tag <?php echo value ?> > <?php echo
value ?></htmltag> days are over...
I agree completely! I hate that messy crap that results from mixing
markup with PHP.
Sancar, you seem to have had some very negative experiences with
templating systems that were either hard to understand or poorly designed.
I sympathise with you, but you may have let your disappointment cloud your
perceptions on this subject. It isn't necessary to throw out the concept
of separation of markup from logic just because many attempts to implement
it have failed.
I'll be very interested to see where Satyam's pre-processor work leads.
It's possible, if not probable, that someday I'll be convinced that inline
markup assembly is as desirable as, say, inline SQL processing.
Warm regards,
Paul
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Dear Paul,
Many thanks for replaying my message, It was very helpful and now I really
understood why I so negative for templating systems...
I haven't got programer background or education. I'm self learner.
Many of php programmers have other programming experiences, and if I
understand correctly their thinking was very different than me. They taking
html elements as programming variables.
And because of this they want to use tpl files, because that html vas broken
their code structure.
And In my aproach, I thinking php and html are combined. When thinking code in
my mind I realize it with HTML. And my aproach uses combination both of them.
This is about to how I educade my mind.
And thats why I jumped satyam idea, because html doesn't fit in php naturally,
I have to to some ".." things to combine php and HTML and his aproach very
close to use html tags naturally in php code.
Also you are right that bad tpl experience, I spend my last 3 months to
understand a project uses heavy tpl thing. I was very very messed. Of course
this programmer responsibility.
And one thing. If I remember correctly one of the Larsmus web presentation
(its about to performance, Getting rich via php or someting like that) says
reducing includes gives some kind of edge about performance.
Regards.
Sancar
--- End Message ---
--- Begin Message ---
var_dump() gives me this:
array(1) {
["1.2"]=>
array(2) {
["code"]=>
array(1) {
[0]=>
string(3) "111"
}
["status"]=>
array(1) {
[0]=>
string(3) "new"
}
}
}
I'm trying to set a variable to that "1.2". Shouldn't I be able to
get it with $var = $arr[0][0]?
--- End Message ---
--- Begin Message ---
Well, I've only just fallen out of bed, but I'd say you'd be able to
access it via $var[0][0][0] as in $var["1.2"]["code"][0] to change 111
to something else and $var["1.2"]["status"][0] to set/change "new".
I must say this looks like an overly complicated array for what it
serves. A little OOP could come in handy to organize all that in more
friendly and efficient way ...
Brian Dunning wrote:
> var_dump() gives me this:
>
> array(1) {
> ["1.2"]=>
> array(2) {
> ["code"]=>
> array(1) {
> [0]=>
> string(3) "111"
> }
> ["status"]=>
> array(1) {
> [0]=>
> string(3) "new"
> }
> }
> }
>
> I'm trying to set a variable to that "1.2". Shouldn't I be able to get
> it with $var = $arr[0][0]?
>
> --PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--- End Message ---
--- Begin Message ---
Jan Schröter wrote:
Hi all! I'm having trouble with my server(s) for some weeks now and did
not find
any solution for now. My System is Opensuse 10.1 (32 bit) with Apache
2.2.3 and
PHP 4.4.5-dev as apache module (latest stable CVS, but wasn't the
solution).
Im having abrupt segmentation faults in my Apache errorlog. Most
frequently the
problem seems to appear while accessing the start page of an actual Joomla
installation, but i've had the error with an Worpress too. So it cannot be
isolated to some php Scripts. Sadly i am not able to reproduce this
error - when
it appears it will not go until an apache restart, but then everything
works
fine for some time (maybe hours or even days).
Here is a gdb backtrace of the request which died with a segmentation
fault.
Hopefully someon can help me with this. If you need any further details,
tell
me, and please also tell me how to obtain this information ;-).
If nobody provides information then try the -internals list, they'll
probably be able to help a bit more.
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
Chris wrote:
If nobody provides information then try the -internals list, they'll
probably be able to help a bit more.
Thanks a lot! I've done so, because it's very urgent.
--- End Message ---
--- Begin Message ---
[EMAIL PROTECTED] wrote:
hi,
I had to move my osComerce store to new hosting company. new server runs
on php5/mysql5.
got this error:
FATAL ERROR: register_globals is disabled in php.ini, please enable it!
since evenon old server globals was Off I was adding
<ifModule mod_php4.c>
php_value register_globals 1
</ifModule>
Now, I tried with
<ifModule mod_php5.c>
php_value register_globals On
</ifModule>
but it doesn't work.
Maybe your host doesn't allow it to be changed through a htaccess..
Is htaccess support enabled?
Put garbage in the file (random chars) and if you get a 500 internal
server error, htaccess files work.. if you don't, that's the problem.
Also I think apache is case sensitive:
<IfModule mod_php5.c>
^^^^^^^^^
(not 100% sure but worth a try).
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
Dear all,
I use php version 4.4.2. When i use mssql and sybase extention, they are
conflict together. I don't know how to using them together.
Please help me...
Thanks & Best Regard
--- End Message ---
--- Begin Message ---
Hi Richard,
Hi all,
The include path is correct. That was one of the first things I played around
with. At the moment, it's include_path = ".". I also tried renaming the
php.ini file to php.ini.off so that it wasn't found and took all the
defaults, but with no success.
Last night I built PHP 5.1.6 and took the same php.ini file. Everything
worked. The build environment was the same, the configure arguments were the
same, only the php version was different.
I'm guessing that I've done something wrong somewhere because I haven't found
any references to this problem from any one else. I just have no idea what
it could be. I don't know if it's any help in locating the problem, my build
environment is Solaris 10, Sun Studio 10 with the Sun C and C++ compilers.
# cc-V
Sun C 5.7 2005/01/07
# CC -V
CC: Sun C++ 5.7 2005/01/07
LDFLAGS=-L/opt/sfw/lib -L/usr/sfw/lib -L/usr/lib
-R/opt/sfw/lib:/usr/sfw/lib:/usr/lib:/opt/oracle/instantclient_10_2
CPPFLAGS=-I/opt/sfw/include -I/usr/sfw/include/openssl
-I/usr/local/BerkeleyDB/include -I/usr/include
-I/opt/oracle/instantclient_10_2/sdk/include
CFLAGS=-I/opt/sfw/include -I/usr/sfw/include/openssl
-I/usr/local/BerkeleyDB/include -I/usr/include
-I/opt/oracle/instantclient_10_2/sdk/include
And to your "rant" about the code developers make - I totally agree with you.
As the administrator of a server with close to 600 users who all put their
own applications in their own accounts up, then ask me why it "doesn't work",
I get annoyed at such things too.
regards
Markus
On Thursday 30 November 2006 19:04, Richard Lynch wrote:
> On Thu, November 30, 2006 6:49 am, Markus Mayer wrote:
> > I have a strange problem including files in PHP 5.2.0 running on Unix.
> > If I
> > try to include a file using include 'filename.inc';, everything is
> > fine. As
> > soon as I try to put a "." in front of the file name, for example
> > include './filename.inc';, I get a "failed to open stream: No such
> > file or
> > directory" error. Does anyone have any suggestions as to what is
> > going
> > wrong?` This all works with php 4.4.4 built with the same environment
> > and
> > compiler on the same system.
>
> What is your include path in PHP 5.2.0?
>
> I'm going to go out on a limb and bet a dollar that the PHP 4.4.4
> include_path has "." as one element within the list and that the PHP
> 5.2.0 include_path does NOT have "." within the list.
>
> I.e.:
> 4.4.4 include_path ".:include_test_dir"
> 5.2.0 include_path "include_test_dir"
>
> In the first case, 4.4.4, you've got . in there, so . combined with ./
> will "find" the file you want.
>
> In the second case, 5.2.0, you've got no . in there, so ./ is looking
> in a directory, not the directory you expect, and it ain't finding the
> file because it's not there.
>
> Rant #24, not directed at Markus, but the world at large :-)
> PHP developers should understand and use include_path instead of
> hacking up their source with hard-coded paths and weird sub-directory
> / parent-directory hacks in include/require statements.
>
> It drives me nuts when I install nice software packages, but I can't
> put their components where I want them.
>
> End result:
> rm -rf [insert your nifty project directory name here]
>
> --
> Some people have a "gift" link here.
> Know what I want?
> I want you to buy a CD from some starving artist.
> http://cdbaby.com/browse/from/lynch
> Yeah, I get a buck. So?
--- End Message ---
--- Begin Message ---
On Thursday 30 November 2006 19:04, Richard Lynch wrote:
[snip...]
And of course I forgot to put in the configure arguments....
'./configure' \
'--without-pear' \
'--with-apxs2=/usr/local/apache2/bin/apxs' \
'--enable-mm=shared' \
'--with-mysql=/usr/local/MySQL/mysql-standard-5.0.27-solaris10-sparc' \
'--with-ldap=/usr/local/open-ldap' \
'--with-openssl=/usr/sfw/' \
'--with-zlib' \
'--enable-inline-optimization' \
'--enable-mm=shared' \
'--with-libxml-dir=/usr/local/lib/libxml-2.6.27' \
'--with-oci8=/opt/oracle/instantclient_10_2' \
"$@"
--- End Message ---