php-general Digest 16 May 2011 09:26:51 -0000 Issue 7312
Topics (messages 312791 through 312802):
Re: Functions/methods aliases in PHp 5.2
312791 by: Richard Quadling
312792 by: Andre Polykanine
312793 by: Richard Quadling
Re: Bold links
312794 by: tedd
312795 by: tedd
312796 by: tedd
312797 by: Micky Hulse
312800 by: Adam Richardson
PHP want not write in Database
312798 by: Silvio Siefke
312801 by: Ashley Sheridan
312802 by: Silvio Siefke
CGI/FastCGI problem when debugging
312799 by: taomin
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 ---
On 15 May 2011 21:45, Andre Polykanine <[email protected]> wrote:
> Hi everyone,
>
> Is there any possibility to make a method or function alias in PHP?
> Yes, I know I can do the following:
>
> <?php
> function foo_bar($x) {
> // And so we code...
> return $result;
> }
>
> function FooBar($x) {
> return foo_bar($x)
> }
>
> But maybe there is a more elegant solution?
> Thanks!
Whilst you can do class_alias() - something I use to hide the long
class name for soap services - there isn't a function alias.
But, if you are creating your own functions, then you could use a
closure and that can be assigned to a variable ...
$fn_FooBar = function() { ... };
$fn_FooBar($a, $b, $c);
or
someFunc($fn_FooBar) { ... }
Closures are ideal for callbacks.
Why do you want to alias functions? Is it to obscure the existing name?
If so, take a look at using an encoder. This uses the compiled code
rather than the source to run.
It is faster to run as there is no compile phase and the "code" isn't
very easy to reverse.
--
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY
--- End Message ---
--- Begin Message ---
Hello Richard,
I'd like to make a database wrapping class (yet another one,
aha!) as flexible, as possible.
So I'd like to make possible to call, for example,
$db->num_rows($result)
and
$db->NumRows($result)
And was just wondering :-).
--
With best regards from Ukraine,
Andre
Skype: Francophile
My blog: http://oire.org/menelion (mostly in Russian)
Twitter: http://twitter.com/m_elensule
Facebook: http://facebook.com/menelion
------------ Original message ------------
From: Richard Quadling <[email protected]>
To: Andre Polykanine
Date created: , 12:48:30 AM
Subject: [PHP] Functions/methods aliases in PHp 5.2
On 15 May 2011 21:45, Andre Polykanine <[email protected]> wrote:
> Hi everyone,
>
> Is there any possibility to make a method or function alias in PHP?
> Yes, I know I can do the following:
>
> <?php
> function foo_bar($x) {
> // And so we code...
> return $result;
> }
>
> function FooBar($x) {
> return foo_bar($x)
> }
>
> But maybe there is a more elegant solution?
> Thanks!
Whilst you can do class_alias() - something I use to hide the long
class name for soap services - there isn't a function alias.
But, if you are creating your own functions, then you could use a
closure and that can be assigned to a variable ...
$fn_FooBar = function() { ... };
$fn_FooBar($a, $b, $c);
or
someFunc($fn_FooBar) { ... }
Closures are ideal for callbacks.
Why do you want to alias functions? Is it to obscure the existing name?
If so, take a look at using an encoder. This uses the compiled code
rather than the source to run.
It is faster to run as there is no compile phase and the "code" isn't
very easy to reverse.
--
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
On 15 May 2011 23:06, Andre Polykanine <[email protected]> wrote:
> Hello Richard,
>
> I'd like to make a database wrapping class (yet another one,
> aha!) as flexible, as possible.
> So I'd like to make possible to call, for example,
> $db->num_rows($result)
> and
> $db->NumRows($result)
> And was just wondering :-).
>
> --
> With best regards from Ukraine,
> Andre
> Skype: Francophile
> My blog: http://oire.org/menelion (mostly in Russian)
> Twitter: http://twitter.com/m_elensule
> Facebook: http://facebook.com/menelion
>
> ------------ Original message ------------
> From: Richard Quadling <[email protected]>
> To: Andre Polykanine
> Date created: , 12:48:30 AM
> Subject: [PHP] Functions/methods aliases in PHp 5.2
>
>
> On 15 May 2011 21:45, Andre Polykanine <[email protected]> wrote:
>> Hi everyone,
>>
>> Is there any possibility to make a method or function alias in PHP?
>> Yes, I know I can do the following:
>>
>> <?php
>> function foo_bar($x) {
>> // And so we code...
>> return $result;
>> }
>>
>> function FooBar($x) {
>> return foo_bar($x)
>> }
>>
>> But maybe there is a more elegant solution?
>> Thanks!
>
> Whilst you can do class_alias() - something I use to hide the long
> class name for soap services - there isn't a function alias.
>
> But, if you are creating your own functions, then you could use a
> closure and that can be assigned to a variable ...
>
> $fn_FooBar = function() { ... };
>
> $fn_FooBar($a, $b, $c);
>
> or
>
> someFunc($fn_FooBar) { ... }
>
>
> Closures are ideal for callbacks.
>
> Why do you want to alias functions? Is it to obscure the existing name?
>
> If so, take a look at using an encoder. This uses the compiled code
> rather than the source to run.
>
> It is faster to run as there is no compile phase and the "code" isn't
> very easy to reverse.
A couple of things come to mind.
1 - If you create a subclass and were overriding num_rows(), the
subclass would have to also override NumRows(). Twice as much work.
2 - You could use __call() and __callStatic() magic methods, but you'd
have limited options for documentation then (assuming you use
docblocks.
Personally, I would recommend using 1 naming convention and sticking with it.
Richard.
--
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY
--- End Message ---
--- Begin Message ---
At 10:10 AM -0700 5/10/11, Micky Hulse wrote:
Looking at your site:
http://sperling.com/
Viewing the source code on your homepage, I see <b> used 15 times in
the body copy.
I am assuming that maybe you have no control over that portion of your
site due to the CMS you are using?
Could you imagine using <strong> in all those instances where you used
<b>? Don't you think that would be overkill?
Sorry to everyone for taking this so OT for the PHP list.
Micky:
If you look at my site now, you'll see that the issue has been fixed.
http://sperling.com/
I vaguely remember using <b> tags in the markup for SEO
considerations with the idea that I was going to change them to
<strong> with a search/replace. Unfortunately, that did not happen
until now. Thanks for letting me know.
Cheers,
tedd
--
-------
http://sperling.com/
--- End Message ---
--- Begin Message ---
At 1:46 PM -0400 5/10/11, Adam Richardson wrote:
The rest of the list does show you've read a fair amount in the past month
(just as others on this list, including me), but what does it do to
specifically support your argument?
It was not presented as a list that supported my argument, but rather
as a list of references I read within the last month -- just to show
that I am keeping current on a gamut of topics.
While people may debate the use of <b> and <i> tags, it is clear that
their use is not recommended by many -- and that was my point -- and
the reason why I do not support their use. YMMV.
Again, I greatly respect you, Ted, I have learned much from your posts, and
this discussion does not detract from that. However, I want to make sure the
developers subscribing to the list will consider the use of the <i> and <b>
tags as recommended by the W3C in (X)HTML5.
Adam
Please provide the reference where the W3C recommends using the <b>
and <i> tags. I would like to read that.
Cheers,
tedd
--
-------
http://sperling.com/
--- End Message ---
--- Begin Message ---
At 3:55 PM +0100 5/10/11, Stuart Dallas wrote:
On Tuesday, 10 May 2011 at 15:41, tedd wrote:
>
The world is changing and I don't think any organization can dictate
what is the right/wrong way to do anything. But the good thing here
is that we are left to our own judgement as to what we support and
what we condemn. In my judgment, the <b> and <i> tags present more
problems than they solve so I will continue to not use those tags and
speak against them.
While I don't necessarily disagree with your point about HTML5
bringing back prehistoric tags, I do think it's important to
remember that the fundamental reason for having the spec is that
everyone (developers, browsers, screenreaders, etc) are working from
the same guidelines. You have to assume that HTML5 consumption
devices (both software and hardware) will follow the spec, so as a
developer I think it's important to do the same regardless of your
philosophical arguments against the decisions made when that spec
was written.
-Stuart
Stuart:
As always, you bring wisdom to the argument.
My only concern is that I do have blind users who applaud my disused
of <b> and <i> tags. Regardless of the specs, I tend to listen to
users who have to live with the specs.
It appears that much of the decision-making process have been
influenced by developers to accommodate large companies (i.e.,
Google) rather than the disabled. In fact, many of these companies
still use CAPTCHA's.
So, until I have blind users tell me it doesn't matter any more, I
shall try not use these tags.
Cheers,
tedd
--
-------
http://sperling.com/
--- End Message ---
--- Begin Message ---
Hi Tedd!
On Sun, May 15, 2011 at 4:41 PM, tedd <[email protected]> wrote:
> I vaguely remember using <b> tags in the markup for SEO considerations with
> the idea that I was going to change them to <strong> with a search/replace.
> Unfortunately, that did not happen until now. Thanks for letting me know.
Hehe! I dig it! :)
I definitely dig your site btw. I have found several of the pages
helpful over the years.
Thanks for the good discussion.
Cheers,
Micky
--- End Message ---
--- Begin Message ---
>
> On Sun, May 15, 2011 at 7:48 PM, tedd <[email protected]> wrote:
At 1:46 PM -0400 5/10/11, Adam Richardson wrote:
>
>> The rest of the list does show you've read a fair amount in the past month
>> (just as others on this list, including me), but what does it do to
>> specifically support your argument?
>>
>
> It was not presented as a list that supported my argument, but rather as a
> list of references I read within the last month -- just to show that I am
> keeping current on a gamut of topics.
>
> While people may debate the use of <b> and <i> tags, it is clear that their
> use is not recommended by many -- and that was my point -- and the reason
> why I do not support their use. YMMV.
>
>
> Again, I greatly respect you, Ted, I have learned much from your posts,
>> and
>> this discussion does not detract from that. However, I want to make sure
>> the
>> developers subscribing to the list will consider the use of the <i> and
>> <b>
>> tags as recommended by the W3C in (X)HTML5.
>>
>> Adam
>>
>
> Please provide the reference where the W3C recommends using the <b> and <i>
> tags. I would like to read that.
Ted, you said:
> First, never use <B> -- or <I> for that matter.
Micky pointed out the changes in HTML5, linking to an HTML5 Doctor Article
noting the new semantics of the <i> and <b> tags:
> – http://html5doctor.com/i-b-em-strong-element/
You brought your authority:
> ...my information/position stems from my understanding derived from both
> daily practice and constant reading. In addition to reading links like the
> above (which I read btw), I also read several list provided by disability
> concerns, such as "webdev.lists.d.umn.edu" being the best. In addition to
> all that, I also read several technical books each week re these subjects.
> For example, within this last month I've purchased and read HTML5 by
> Lawson, Smashing CSS by Meyer, 100 Things by Weinschenk, Learning Web Design
> by Robbins, Designing with the Mind in Mind by Johnson, Forms that work by
> Jarret, Build your own web site the right way by Lloyd, PHP 5.3 by Doyle,
> and Expert PHP and MySQL by Cuniosoa. That's a lot of reading, -- so I
> think I keep up with what's going on.
I pointed out that many of us read a great deal, and that the one source you
cited specifically covering HTML5 speaks directly to the use of the <b> (and
<i>) tags within HTML5.
Additionally, let me say that the Lawson-Sharp book you mentioned is a great
read. I also think that HTML5 Doctor (Micky's source) is a great read. HTML
Doctor is a collaboration which includes both Bruce Lawson and Remy Sharp:
http://html5doctor.com/about/
I provided links to the HTML5 spec (draft):
> http://dev.w3.org/html5/spec/Overview.html#the-i-element
http://dev.w3.org/html5/spec/Overview.html#the-b-element
My position can be summarized as below:
1. I will try to follow the HTML5 spec (as it is now, and with the
changes that occur when finalized):
http://dev.w3.org/html5/spec/Overview.html
2. The HTML5 spec has given semantic meanings to the i and b tags, making
them media-independent (nice summaries below, including the link Micky
pointed to initially):
http://html5doctor.com/your-questions-16/
http://html5doctor.com/i-b-em-strong-element/
3. If one works through the other possible options (the spec points out
many other tags that may be more appropriate) and the b or i tag still is
the best fit, they should use it.
4. Of great importance, *I'm not advocating using the b or i tags for
presentation purposes!* Rather, consistent with my earlier emails, I'm
advocating their use for the situations outlined in the spec, when the
semantics can enhance the markup (which is intended to eventually enhance
the experience of those utilizing text-to-speech software.)
Many prominent CSS resets have for some time zeroed out the visual
styling of i and b tags, including Meyer's:
http://meyerweb.com/eric/tools/css/reset/
The use of the tag is now one of semantics, NOT PRESENTATION. The spec
even points out:
Style sheets can be used to format
i<http://dev.w3.org/html5/spec-author-view/the-i-element.html#the-i-element>
elements,
just like any other element can be restyled. Thus, it is not the case that
content in
i<http://dev.w3.org/html5/spec-author-view/the-i-element.html#the-i-element>
elements
will necessarily be italicized.
*
*
If you want to chat more about this topic, Tedd, you can email off list or
we can meet up for a beer (although not this week, my wife is expecting any
time ;)
Adam
--
Nephtali: A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com
--- End Message ---
--- Begin Message ---
Hello,
i have a Blog Script for my private Website. Normal i write new Articles
direct with phpmyadmin, but this is not comfortable. I has no errors in Log
for the script and the mysql query log write the correct insert SQL code, but
nothing would be write in the database. I really understand not where is the
mistake. Can someone help me?
Thank You! Wish nice day at all!
Regards
Silvio
My PHP Code:
<start>
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require ("inc/db.html");
var_dump($_POST);
// Check the Fields
if (isset ($_POST['submit']) &&
isset ($_POST['autor']) &&
isset ($_POST['title']) &&
isset ($_POST['teaser']) &&
isset ($_POST['content']) &&
isset ($_POST['category']) &&
isset ($_POST['bild']) &&
$_POST['autor'] != '' &&
$_POST['title'] != '' &&
$_POST['teaser'] != '' &&
$_POST['content'] != '' &&
$_POST['category'] != '' &&
$_POST['bild'] != '') {
try {
$sql = "INSERT INTO `test` (autor, title, teaser, content, category, bild)
VALUES
(:autor, :title, :teaser, :teaser, :content, :category, :bild)";
$write = $db->prepare($sql);
$write->bindValue(':autor', $_POST['autor']);
$write->bindValue(':title', $_POST['title']);
$write->bindValue(':teaser', $_POST['teaser']);
$write->bindValue(':content', $_POST['content']);
$write->bindValue(':category', $_POST['category']);
$write->bindValue(':bild', $_POST['bild']);
$write->execute();
echo "<h1>Artikel ist eingetragen!</h1>";
} catch (PDOException $ex) {
echo $ex->getMessage();
}
}
?>
</end>
The HTML Tags:
<start>
<div class="entry">
<form method="post" action="" />
<fieldset>
<label>Autor</label>
<input type="text" class="text" name="autor" />
<label>Title</label>
<input type="text" class="text" name="title" />
<label>Teaser</label>
<textarea cols="80" rows="10" class="textarea" name="teaser"></textarea>
<label>Content</label>
<textarea cols="80" rows="10" class="textarea" name="content"></textarea>
<label>Kategorie</label>
<input type="text" class="text" name="category" />
<label>Bild</label>
<input type="text" class="text" name="bild" />
<input type="submit" class="submit" name="submit" value="Posten" />
</fieldset>
</form>
</div>
</end>
The Mysql Query Log:
<start>
110516 2:44:29 187 Connect root@localhost on bloggen
187 Query INSERT INTO `test` (autor, title, teaser,
content, category, bild) VALUES ('Silvio Siefke', 'Test', 'We try we can
write in database with the script.', 'We try we can write in database with
the script.', 'When not then i not know what is the problem with the
script.', 'Freizeit', 'content.png') 187 Quit
<end>
The var_dump give me:
<start>
array(7) { ["autor"]=> string(13) "Silvio Siefke" ["title"]=> string(4)
"Test" ["teaser"]=> string(48) "We try we can write in database with the
script." ["content"]=> string(61) "When not then i not know what is the
problem with the script." ["category"]=> string(8) "Freizeit" ["bild"]=>
string(11) "content.png" ["submit"]=> string(6) "Posten" }
<end>
--- End Message ---
--- Begin Message ---
On Mon, 2011-05-16 at 02:55 +0200, Silvio Siefke wrote:
> Hello,
>
> i have a Blog Script for my private Website. Normal i write new Articles
> direct with phpmyadmin, but this is not comfortable. I has no errors in Log
> for the script and the mysql query log write the correct insert SQL code, but
> nothing would be write in the database. I really understand not where is the
> mistake. Can someone help me?
>
> Thank You! Wish nice day at all!
>
> Regards
> Silvio
>
>
> My PHP Code:
> <start>
> <?php
> error_reporting(E_ALL);
> ini_set('display_errors', 1);
> require ("inc/db.html");
> var_dump($_POST);
>
> // Check the Fields
> if (isset ($_POST['submit']) &&
> isset ($_POST['autor']) &&
> isset ($_POST['title']) &&
> isset ($_POST['teaser']) &&
> isset ($_POST['content']) &&
> isset ($_POST['category']) &&
> isset ($_POST['bild']) &&
> $_POST['autor'] != '' &&
> $_POST['title'] != '' &&
> $_POST['teaser'] != '' &&
> $_POST['content'] != '' &&
> $_POST['category'] != '' &&
> $_POST['bild'] != '') {
>
>
> try {
>
> $sql = "INSERT INTO `test` (autor, title, teaser, content, category, bild)
> VALUES
> (:autor, :title, :teaser, :teaser, :content, :category, :bild)";
>
> $write = $db->prepare($sql);
> $write->bindValue(':autor', $_POST['autor']);
> $write->bindValue(':title', $_POST['title']);
> $write->bindValue(':teaser', $_POST['teaser']);
> $write->bindValue(':content', $_POST['content']);
> $write->bindValue(':category', $_POST['category']);
> $write->bindValue(':bild', $_POST['bild']);
> $write->execute();
> echo "<h1>Artikel ist eingetragen!</h1>";
>
>
> } catch (PDOException $ex) {
> echo $ex->getMessage();
> }
> }
> ?>
> </end>
>
> The HTML Tags:
> <start>
> <div class="entry">
> <form method="post" action="" />
> <fieldset>
> <label>Autor</label>
> <input type="text" class="text" name="autor" />
>
> <label>Title</label>
> <input type="text" class="text" name="title" />
>
> <label>Teaser</label>
> <textarea cols="80" rows="10" class="textarea" name="teaser"></textarea>
>
> <label>Content</label>
> <textarea cols="80" rows="10" class="textarea" name="content"></textarea>
>
> <label>Kategorie</label>
> <input type="text" class="text" name="category" />
>
> <label>Bild</label>
> <input type="text" class="text" name="bild" />
> <input type="submit" class="submit" name="submit" value="Posten" />
> </fieldset>
> </form>
> </div>
> </end>
>
> The Mysql Query Log:
> <start>
> 110516 2:44:29 187 Connect root@localhost on bloggen
> 187 Query INSERT INTO `test` (autor, title, teaser,
> content, category, bild) VALUES ('Silvio Siefke', 'Test', 'We try we can
> write in database with the script.', 'We try we can write in database with
> the script.', 'When not then i not know what is the problem with the
> script.', 'Freizeit', 'content.png') 187 Quit
> <end>
>
> The var_dump give me:
> <start>
> array(7) { ["autor"]=> string(13) "Silvio Siefke" ["title"]=> string(4)
> "Test" ["teaser"]=> string(48) "We try we can write in database with the
> script." ["content"]=> string(61) "When not then i not know what is the
> problem with the script." ["category"]=> string(8) "Freizeit" ["bild"]=>
> string(11) "content.png" ["submit"]=> string(6) "Posten" }
> <end>
>
What is your code in the included db.html? You do realise that unless
you've told the server especially that it won't know to parse your HTML
files for PHP code as well. HTML is embedded in PHP, not the other way
around. If you think more like that, you'll realise why it's not
working.
--
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
Hello,
On Mon, 16 May 2011 07:13:19 +0100 Ashley Sheridan wrote:
> What is your code in the included db.html? You do realise that unless
> you've told the server especially that it won't know to parse your HTML
> files for PHP code as well. HTML is embedded in PHP, not the other way
> around. If you think more like that, you'll realise why it's not
> working.
in the db.html is the follow code:
<start>
try {
$db = new PDO("mysql:host={$host};dbname={$database}", $user, $pass);
}catch(PDOException $pe)
{ die('Connection error, because: ' .$pe->getMessage());
}
<end>
Yes my Webserver parse html files as php. My formular work without problems,
and the old Blog Script work too without problems.
Regards
Silvio
--- End Message ---
--- Begin Message ---
Hi, everyone,
I built a project base on ZF in Zend Studio 8, and run well. But when I
debug the index.php as PHP Web Page, it always get the index.php file "save
as", and then an CGI/FastCGI error, soon or later.
I use Zend Debugger, and Local Zend server.
I googled much , and have changed settings about some timing controls. Like:
C:\..\Zend\ZendServer\etc \ZendEnablerConf.xml
<Timeouts connectionTimeout="60" requestTimeout="120" /> to <Timeouts
connectionTimeout="600" requestTimeout="1200" />
And, in Zend Server-Server Setup-Directives, change the
"max_execution_time"to 600,restart php and Apache-Zend。Also I shut down the
time limit in
"ZendServer/GUI/applications/CE/models/Plugins/Initializer/CE.php" (
//set_time_limit(60);)
But the index.php"save as " and the CGI problem still there.
I checked Zend Server's httpd.conf and Zend.conf, nothing weird. Testing
debugger in Zend Studio also succced.
And more strangely, if I hold the F5 key, let the debugger step quickly, it
has a big chance to get this in brower:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable
to complete your request.
Please contact the server administrator, [email protected] and inform them
of the time the error occurred, and anything you might have done that may
have caused the error.
More information about this error may be available in the server error log.
At the same time, the address bar will be:
http://localhost:8081/quickstart/quickstart/public/index.php?debug_host=192.
168.0.181%2C127.0.0.1&debug_fastfile=1&start_debug=1&debug_port=10137&use_re
mote=1&original_url=http%3A%2F%2Flocalhost%3A8081%2Fquickstart%2Fquickstart%
2Fpublic%2Findex.php&send_sess_end=1&debug_stop=1&debug_start_session=1&debu
g_no_cache=1305510553167&debug_session_id=1007
the ip address "192.168.0.181" is my laptop's wireless ip, but I have
already set the ServerName to 127.0.0.1 in Zend server's httpd.conf. So why
the debug_host will be 192.168.0.181? Dose this can figure any clue to my
problem above?
I have ticked around here for 3 days. Any help appreciated!!
Best Wishes.
--- End Message ---