|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general-digest-help
lists.php.net
Date: Wed Apr 02 2008 - 13:50:38 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 2 Apr 2008 18:50:38 -0000 Issue 5382
Topics (messages 272430 through 272456):
Re: array with null shows different with print_r and var_dump
272430 by: Casey
272432 by: Robert Cummings
Re: APC & FastCGI != upload progress ?
272431 by: Manuel Lemos
Re: Reporting mail as spam
272433 by: Manuel Lemos
Re: how to possibly cache something and the theory of better performance / better speed
272434 by: Per Jessen
help needed building php_dblib for PHP 5.2.5 on windows
272435 by: Jason
E-Library Software
272436 by: Ali Reza Sajedi
272437 by: Wolf
272446 by: Daniel Brown
OT -> Hosting Services for Non-profit
272438 by: Wolf
272442 by: Daniel Brown
cuRL script won't submit
272439 by: Test User
272440 by: Test User
272441 by: Daniel Brown
272444 by: Test User
272445 by: Daniel Brown
Help with inputbox
272443 by: Ricardo Pinto
272449 by: Wolf
an easy destroying session issue...
272447 by: pere roca
272448 by: Daniel Brown
Re: autoload with namespace
272450 by: Nathan Nobbe
272451 by: Jochem Maas
272452 by: Richard Heyes
272453 by: Ryan Panning
272454 by: Nathan Nobbe
272455 by: Nathan Nobbe
272456 by: Richard Heyes
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
On Tue, Apr 1, 2008 at 11:49 PM, Sanjay Mantoor
<sanjay.mantoor
gmail.com> wrote:
> Hello,
>
> I am new to PHP and PHP community.
>
> Following program outputs different values with print_r and var_dump.
>
> $array = array(null, NULL);
>
> print_r($array); prints values like below
> Array
> (
> [0] =>
> [1] =>
> )
>
print_r converts null, which is a variable type, like integer, string,
float, etc, into an empty string.
> where as var_dump($array) prints values like below
> array(2) {
> [0]=>
> NULL // Does this convert to null to NULL?
null is case-insensitive, so it doesn't matter how you type it.
> [1]=>
> NULL
> }
var_dump converts null into the string "NULL".
>
> Can you tell me why the above difference?
>
--
-Casey
attached mail follows:
On Wed, 2008-04-02 at 12:19 +0530, Sanjay Mantoor wrote:
> Hello,
>
> I am new to PHP and PHP community.
>
> Following program outputs different values with print_r and var_dump.
>
> $array = array(null, NULL);
>
> print_r($array); prints values like below
> Array
> (
> [0] =>
> [1] =>
> )
>
> where as var_dump($array) prints values like below
> array(2) {
> [0]=>
> NULL // Does this convert to null to NULL?
> [1]=>
> NULL
> }
>
> Can you tell me why the above difference?
NULL and null are the same thing. If I'm correct var_dump() was created
to solve the problem of not knowing what the datatypes are when using
print_r().
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
attached mail follows:
Hello,
on 03/30/2008 02:52 PM steve said the following:
> Hmmm... I am working on a PHP daemon for comet style connections...
> I'll keep that idea in mind. I guess that using Flash is best solution
> at the moment.. at least the only one I have working...
I implement COMET connections with plain HTML with an hidden iframe.
Actually I have been using that for a upload progress meter among other
AJAX uses. Actually it is an AJAX plug-in of this forms class:
http://www.phpclasses.org/formsgeneration
Here is an example of a form upload progress done all in PHP and plain HTML:
http://www.meta-language.net/forms-examples.html?example=test_upload_progress
Here you can watch a tutorial video that explains the COMET AJAX
implementation:
http://www.phpclasses.org/browse/video/1/package/1/section/plugin-ajax.html
> I'm guessing that FastCGI is buffering the upload until complete. PHP
> docs might want to document that.
>
> FastCGI is also breaking Apache's deflate module, but that is another issue...
Couldn't it be deflate buffering FastCGI output?
--
Regards,
Manuel Lemos
PHP professionals looking for PHP jobs
http://www.phpclasses.org/professionals/
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
attached mail follows:
Hello,
On Mon, Mar 31, 2008 at 12:01 PM, Sándor Tamás wrote:
> Hi,
>
> I wrote a little registration routine, which will send a confirmation letter to the user with a random number in the message body (my site is on a host, so I can't write in the subject, and ask the user to reply), which can be clicked then, and my site will finish the registration. My big problem is, that this host inserts an X header to the mail which identifies my PHP script as the X-PHP. As I recognize, this header adds a huge number to the spam score. Is there any possibility, to reduce the other scores? By the way, what counts most in a spam?
I agree with Richard, sending the messages as plain text may reduce your
chances of having your messages confused with spam.
But even plain text messages can be confused of spam often for not being
well-formed according to e-mail standards.
It is hard to tell what you may be doing wrong without seeing your code.
Anyway, I recommend you this popular PHP MIME message class that I use
that knows how to send e-mail standards compliant messages:
http://www.phpclasses.org/mimemessage
--
Regards,
Manuel Lemos
PHP professionals looking for PHP jobs
http://www.phpclasses.org/professionals/
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
attached mail follows:
Joey wrote:
> OK now, getting greedy I want to take it to another level. Instead of
> having to read the folder for images every time, why not read the
> image names into a file so that we can maintain therbey caching the
> list.
Your filesystem cache will do that for you anyway.
/Per Jessen, Zürich
attached mail follows:
Hi all,
I have previously posted this on the windows specific list, however I
believe this list reaches a wider audience so i'll try again.
I am trying to recompile php 5.2.5 on win32, specifically trying to
rebuild the freetds extension with the latest RC code from FreeTDS.org.
I am getting a persistent linking error however and am at a loss as
to what is causing it. The build environment is VC6 SP6 on WinXP x86 SP2.
The exact error is:
main\internal_functions.c(69) : error C2065: 'phpext_dblib_ptr' :
undeclared identifier
main\internal_functions.c(69) : error C2099: initializer is not a constant
NMAKE : fatal error U1077: '"cl.exe"' : return code '0x2'
Help!, Anyone?
TIA
Jason
attached mail follows:
Hello,
I am looking for an open source php based E-Library sofware.
Could anybody help?
Regards
Ali
attached mail follows:
STFW
What has your searches on Google turned up?
What about your browsing through sourceforge?
---- Ali Reza Sajedi <arsajedi
khanehjou.com> wrote:
> Hello,
>
> I am looking for an open source php based E-Library sofware.
>
> Could anybody help?
>
> Regards
>
> Ali
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
attached mail follows:
On Wed, Apr 2, 2008 at 7:57 AM, Wolf <lonewolf
nc.rr.com> wrote:
> STFW
>
> What has your searches on Google turned up?
>
> What about your browsing through sourceforge?
Not to mention the the question, since your first message didn't
get any responses from the list three days ago, why didn't you at
least re-word it or add more details?
--
</Daniel P. Brown>
Dedicated servers starting
$59.99/mo., VPS starting
$19.99/mo.,
and shared hosting starting
$2.50/mo.
Just ask!
attached mail follows:
I know there is at least 1 hoster on this list...
I have a friend who works for a non-profit and they are currently looking for a new place to host their domain including the site and the email.
I'm not sure what they can pay or anything at this point, but I figured I'd see about checking with you guys and see what options they have.
Their other thought is hosting internal since the ISPs they are talking to are willing to do the DNS stuff as well, but currently it's an up-in-the-air process.
Thanks!
Wolf
attached mail follows:
On Wed, Apr 2, 2008 at 8:40 AM, Wolf <lonewolf
nc.rr.com> wrote:
> I know there is at least 1 hoster on this list...
>
> I have a friend who works for a non-profit and they are currently looking for a new place to host their domain including the site and the email.
>
> I'm not sure what they can pay or anything at this point, but I figured I'd see about checking with you guys and see what options they have.
>
> Their other thought is hosting internal since the ISPs they are talking to are willing to do the DNS stuff as well, but currently it's an up-in-the-air process.
Wolf,
Either contact me off-list or pass my information on to them so
that I can find out what they'll need. I do shared, VPS, and
dedicated servers, so it shouldn't be a problem.
--
</Daniel P. Brown>
Forensic Services, Senior Unix Engineer
1+ (570-) 362-0283
attached mail follows:
why will this script not submit the form - it does input data into the form - but not submit it. below is the script and then the html form.. thanks
#!/usr/bin/php
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_COOKIEFILE, "/temp/cookie.txt");
curl_setopt($ch, CURLOPT_URL,"http://192.168.10.10/?link=answer&l=c&qid=25AA98zRa";);
curl_setopt ($ch, CURLOPT_POSTFIELDS, "link=answer&qid=25AA98zRa&.crumb=x88&textarea=here+ya+go&prev_ans_page=&e=0&sumbit1=Sumbit");
$result = curl_exec ($ch);
curl_close ($ch);
echo $result;
?>
/////////////////////////////// below is the HTML form \\\\\\\\\\\\\\\\\\\\\\\\\\\
<form action="/question/act;_lt=Aktsgb5HMZ0vBEUSHj_3I1YdzKIX;_lv=3" onsubmit="this.submit1.disabled=true;" method="post" name="template_form">
<input type="hidden" value="answer" name="link"/>
<input type="hidden" value="25AA98zRa" name="qid"/>
<input type="hidden" value="x88" name=".crumb"/>
<input type="hidden" value="" name="textarea"/>
<input type="hidden" value="" name="refer"/>
<input type="hidden" value="" name="prev_ans_page"/>
<input type="hidden" value="0" name="e"/>
<input class="button" type="submit" name="submit1" value="Submit"/>
</form>
____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.
http://tc.deals.yahoo.com/tc/blockbuster/text5.com
attached mail follows:
I added more info below and corrected the spelling of a word - very sorry to add more to your already full mailbox
why will this script not submit the form - it does input data into the form - but not submit it. below is the script and then the html form.. thanks
#!/usr/bin/php
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_COOKIEFILE, "/temp/cookie.txt");
curl_setopt($ch, CURLOPT_URL,"http://192.168.10.10/?link=answer&l=c&qid=25AA98zRa";);
curl_setopt ($ch, CURLOPT_POSTFIELDS, "link=answer&qid=25AA98zRa&.crumb=x88&textarea=here+ya+go&prev_ans_page=&e=0&submit1=Submit");
$result = curl_exec ($ch);
curl_close ($ch);
echo $result;
?>
/////////////////////////////// below is the HTML form \\\\\\\\\\\\\\\\\\\\\\\\\\\
<form action="/question/act;_lt=Aktsgb5HMZ0vBEUSHj_3I1YdzKIX;_lv=3" onsubmit="this.submit1.disabled=true;" method="post" name="template_form">
<input type="hidden" value="answer" name="link"/>
<input type="hidden" value="25AA98zRa" name="qid"/>
<input type="hidden" value="x88" name=".crumb"/>
<input type="hidden" value="" name="textarea"/>
<input type="hidden" value="" name="refer"/>
<input type="hidden" value="" name="prev_ans_page"/>
<input type="hidden" value="0" name="e"/>
<input class="button" type="submit" name="submit1" value="Submit"/>
</form>
____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.
http://tc.deals.yahoo.com/tc/blockbuster/text5.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.
http://tc.deals.yahoo.com/tc/blockbuster/text5.com
attached mail follows:
On Wed, Apr 2, 2008 at 9:24 AM, Test User <usertest90
yahoo.com> wrote:
> why will this script not submit the form - it does input data into the form - but not submit it. below is the script and then the html form.. thanks
>
[snip!]
> curl_setopt($ch, CURLOPT_URL,"http://192.168.10.10/?link=answer&l=c&qid=25AA98zRa";);
[snip!]
> /////////////////////////////// below is the HTML form \\\\\\\\\\\\\\\\\\\\\\\\\\\
>
> <form action="/question/act;_lt=Aktsgb5HMZ0vBEUSHj_3I1YdzKIX;_lv=3" onsubmit="this.submit1.disabled=true;" method="post" name="template_form">
[snip!]
Because you're submitting it to the wrong page. What you're doing
will submit to the default (index) page in that directory, as opposed
to the form action. Change this:
curl_setopt($ch,
CURLOPT_URL,"http://192.168.10.10/?link=answer&l=c&qid=25AA98zRa";);
curl_setopt ($ch, CURLOPT_POSTFIELDS,
"link=answer&qid=25AA98zRa&.crumb=x88&textarea=here+ya+go&prev_ans_page=&e=0&submit1=Submit");
To this:
curl_setopt($ch,
CURLOPT_URL,"http://192.168.10.10/question/act;_lt=Aktsgb5HMZ0vBEUSHj_3I1YdzKIX;_lv=3");
curl_setopt ($ch, CURLOPT_POSTFIELDS,
"link=answer&qid=25AA98zRa&.crumb=x88&textarea=here+ya+go&prev_ans_page=&e=0&submit1=Submit");
Also, note two things:
1.) I removed the semicolon from the end of the CURLOPT_URL
value (between the quotes and parentheses).
2.) The form action looks like it's most likely dynamic, so
you'll have to think of a workaround yourself if it is.
--
</Daniel P. Brown>
Forensic Services, Senior Unix Engineer
1+ (570-) 362-0283
attached mail follows:
many thanks.. I have been working on this for weeks!
now I have to figure out how to extract that dynamic URL from the form before I post..
----- Original Message ----
From: Daniel Brown <parasane
gmail.com>
To: Test User <usertest90
yahoo.com>
Cc: php-general
lists.php.net
Sent: Wednesday, April 2, 2008 8:54:16 AM
Subject: Re: [PHP] cuRL script won't submit
On Wed, Apr 2, 2008 at 9:24 AM, Test User <usertest90
yahoo.com> wrote:
> why will this script not submit the form - it does input data into the form - but not submit it. below is the script and then the html form.. thanks
>
[snip!]
> curl_setopt($ch, CURLOPT_URL,"http://192.168.10.10/?link=answer&l=c&qid=25AA98zRa";);
[snip!]
> /////////////////////////////// below is the HTML form \\\\\\\\\\\\\\\\\\\\\\\\\\\
>
> <form action="/question/act;_lt=Aktsgb5HMZ0vBEUSHj_3I1YdzKIX;_lv=3" onsubmit="this.submit1.disabled=true;" method="post" name="template_form">
[snip!]
Because you're submitting it to the wrong page. What you're doing
will submit to the default (index) page in that directory, as opposed
to the form action. Change this:
curl_setopt($ch,
CURLOPT_URL,"http://192.168.10.10/?link=answer&l=c&qid=25AA98zRa";);
curl_setopt ($ch, CURLOPT_POSTFIELDS,
"link=answer&qid=25AA98zRa&.crumb=x88&textarea=here+ya+go&prev_ans_page=&e=0&submit1=Submit");
To this:
curl_setopt($ch,
CURLOPT_URL,"http://192.168.10.10/question/act;_lt=Aktsgb5HMZ0vBEUSHj_3I1YdzKIX;_lv=3");
curl_setopt ($ch, CURLOPT_POSTFIELDS,
"link=answer&qid=25AA98zRa&.crumb=x88&textarea=here+ya+go&prev_ans_page=&e=0&submit1=Submit");
Also, note two things:
1.) I removed the semicolon from the end of the CURLOPT_URL
value (between the quotes and parentheses).
2.) The form action looks like it's most likely dynamic, so
you'll have to think of a workaround yourself if it is.
--
</Daniel P. Brown>
Forensic Services, Senior Unix Engineer
1+ (570-) 362-0283
____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.
http://tc.deals.yahoo.com/tc/blockbuster/text5.com
attached mail follows:
On Wed, Apr 2, 2008 at 10:23 AM, Test User <usertest90
yahoo.com> wrote:
> many thanks.. I have been working on this for weeks!
> now I have to figure out how to extract that dynamic URL from the form before I post..
This may help to start:
<?php
$data = file_get_contents('http://www.website.com/html_form.html');
preg_match('/form action="(.*)"/Uis',$data,$matches);
print_r($matches);
?>
--
</Daniel P. Brown>
Dedicated servers starting
$59.99/mo., VPS starting
$19.99/mo.,
and shared hosting starting
$2.50/mo.
Just ask!
attached mail follows:
Description:
------------
text including spaces placed in an input text control in HTML show the
whole text.
text including spaces placed in an input text control in PHP does not
show the whole text, only the first word up to the first space is
displayed. The same happens with variables from a BD.
My code:
$result = mysql_query("SELECT id, creation, modif, origin_val, dealer_id,
concat(ifnull(name_1,' '),' ',ifnull(name_2,' '),' ', ifnull(name_3,' ')) as
NOME
FROM crm_entity where id=$x");
$row = mysql_fetch_array($result);
$id = $row['id'];
$creation = $row['creation'];
echo"$creation";
$modif = $row['modif'];
$origin_val = $row['origin_val'];
$dealer_id = $row['dealer_id'];
$name = $row['NOME'];
echo "
<div id=\"quadro_1\">ID : $x
Criação: <input type=\"text\" size=\"50\" maxlength=\"12\"
name=\"\" value=$creation>
Modificação: <input type=\"text\" size=\"50\" maxlength=\"50\"
name=\"\" value=$modif>
Origin_Val: <input type=\"text\" size=\"10\" maxlength=\"50\"
name=\"\" value=$origin_val>
Dealer_Id: <input type=\"text\" size=\"10\" maxlength=\"50\"
name=\"\" value=$dealer_id><br><br>
Name: <input type=\"text\" size=\"10\" maxlength=\"50\" name=\"\"
value=$name>
</div>
<br><br>
";
--> There's more code, but is the same steps....
Output
ID : 100002 Criação: Modificação: Origin_Val: Dealer_Id:
Num_cli: NIF: Crm Code: Type_Val:
Titulo: Trato: Origin_Val:
Nome 1: Eolmar- Escola de Condução de Magalhães e SÁ, Lda Nome 2: Nome 3:
Nome:
Short Name: Sector de Actividade:
The date that appear has seconds, etc...in the field "Nome 1" only appears
the first one...the rest after the space doesn't appear! Everything after
the space don't appear....
Can you help me please?? It's Urgent!
Thanks!!
Ricardo Pinto
attached mail follows:
<!-- SNIP -->
> <div id=\"quadro_1\">ID : $x
>
> Criação: <input type=\"text\" size=\"50\" maxlength=\"12\"
> name=\"\" value=$creation>
> Modificação: <input type=\"text\" size=\"50\" maxlength=\"50\"
> name=\"\" value=$modif>
> Origin_Val: <input type=\"text\" size=\"10\" maxlength=\"50\"
> name=\"\" value=$origin_val>
> Dealer_Id: <input type=\"text\" size=\"10\" maxlength=\"50\"
> name=\"\" value=$dealer_id><br><br>
> Name: <input type=\"text\" size=\"10\" maxlength=\"50\" name=\"\"
> value=$name>
> </div>
> <br><br>
> ";
> --> There's more code, but is the same steps....
<!-- SNIP -->
You aren't encapsulating the text, escape double quote the value field (like you did for the rest of the fields) and you are good to go.
IE:
Name: <input type=\"text\" size=\"10\" maxlength=\"50\" name=\"\"
value=\"$name\">
Wolf
attached mail follows:
for destroying the session without closing the browser it should work...
<?php
session_start();
$_SESSION = array();
session_destroy();
$userid = safehtml($_POST['userid']);
session_start();
//$sessionid can be used to retrieve the current name and session id as a
string
$sessionid=session_id();
//userid can be re-used as a variable in other php files
session_register("userid");
After leaving the page and coming back, without closing the browser, and
performing a SQL sentence like "insert into user_table values
('$userid','$sessionid')"; I get sessionid is still the same!! why¿?
thanks,
Pere
--
View this message in context: http://www.nabble.com/an-easy-destroying-session-issue...-tp16447090p16447090.html
Sent from the PHP - General mailing list archive at Nabble.com.
attached mail follows:
On Wed, Apr 2, 2008 at 10:34 AM, pere roca <peroc79
gmail.com> wrote:
>
> <?php
> session_start();
> $_SESSION = array();
> session_destroy();
>
> $userid = safehtml($_POST['userid']);
> session_start();
>
> //$sessionid can be used to retrieve the current name and session id as a
> string
> $sessionid=session_id();
> //userid can be re-used as a variable in other php files
> session_register("userid");
>
> After leaving the page and coming back, without closing the browser, and
> performing a SQL sentence like "insert into user_table values
> ('$userid','$sessionid')"; I get sessionid is still the same!! why¿?
This is expected behavior. Calling session_destroy() only removes
the data associated with the session. To kill the PHPSESSID value,
RTFM: http://php.net/manual/en/function.session-destroy.php
--
</Daniel P. Brown>
Dedicated servers starting
$59.99/mo., VPS starting
$19.99/mo.,
and shared hosting starting
$2.50/mo.
Just ask!
attached mail follows:
On Tue, Apr 1, 2008 at 8:28 PM, Ryan Panning <rpanning
gmail.com> wrote:
> I haven't been keeping an eye on this list so if this has come up before
> please point me in the right direction. :)
>
> Playing around with dev PHP 5.3 and namespaces, I'm finding it hard to
> write an autoload function. Since autoload will be triggered on any
> namespace call, the request could be for a namespace function or constant.
> Ex:
>
> FOO::BAR::me() ## A namespace function or class static function?
> FOO::BAR::ME ## A namespace constant or class constant?
>
> Since there isn't really a way for PHP to know what it is looking for,
> what would be a good method to write the autoload? Assuming the file
> structure:
>
> - Namespaces are in separate directories NS1::NS2::Class1 ==
> NS1/NS2/class.Calss1.php
> - Namespace files and class files are prefixed with ns.*.php and
> class.*.php (respectively)
i havent gotten the chance to work w/ 5.3 yet (been burried w/ other crap
lately) anyways ive been wondering about an autoloader in 5.3 so this is a
cool thread ;) well i would probly just extend my mechanism for pre-5.3 and
that is essentially to populate an array of absolute paths to your files.
in ur case each path would map directly to a package followed by the class
that contains it. so then ur autoloader just looks at the mapping when a
request comes in, checks the appropriate index in this array and calls
require or w/e on the abs path.
there is one curiosity / caveat underlying the 5.3 implementation... so
does the namespace get supplied to the autoload function as well as the
class name? is it just one big string or are they separate?
-nathan
attached mail follows:
Nathan Nobbe schreef:
> On Tue, Apr 1, 2008 at 8:28 PM, Ryan Panning <rpanning
gmail.com> wrote:
>
>> I haven't been keeping an eye on this list so if this has come up before
>> please point me in the right direction. :)
>>
>> Playing around with dev PHP 5.3 and namespaces, I'm finding it hard to
>> write an autoload function. Since autoload will be triggered on any
>> namespace call, the request could be for a namespace function or constant.
>> Ex:
>>
>> FOO::BAR::me() ## A namespace function or class static function?
>> FOO::BAR::ME ## A namespace constant or class constant?
>>
>> Since there isn't really a way for PHP to know what it is looking for,
>> what would be a good method to write the autoload? Assuming the file
>> structure:
>>
>> - Namespaces are in separate directories NS1::NS2::Class1 ==
>> NS1/NS2/class.Calss1.php
>> - Namespace files and class files are prefixed with ns.*.php and
>> class.*.php (respectively)
>
>
> i havent gotten the chance to work w/ 5.3 yet (been burried w/ other crap
> lately) anyways ive been wondering about an autoloader in 5.3 so this is a
> cool thread ;) well i would probly just extend my mechanism for pre-5.3 and
> that is essentially to populate an array of absolute paths to your files.
> in ur case each path would map directly to a package followed by the class
> that contains it. so then ur autoloader just looks at the mapping when a
> request comes in, checks the appropriate index in this array and calls
> require or w/e on the abs path.
>
> there is one curiosity / caveat underlying the 5.3 implementation... so
> does the namespace get supplied to the autoload function as well as the
> class name? is it just one big string or are they separate?
one big string. how does php know before hand whether foo::get() is a
namespaced function call or a static class method call?
the OP has a point about autoloading this stuff - I can only see problems arising,
mostly because the namespace seperator is the same as class/method seperator ...
something that seems to be compounded by the fact that you can spoof nested namespaces
ala:
namespace My::Pseudo::Nested::NS;
I have been following the namespace developments and have my doubt that it solves the
symbol clashing issues in a way that doen't just move the headache to somewhere else
(as opposed to eradicate it).
I haven't bothered to play with it yet ... I figure the functionality will require
a few version before the wrinkles are ironed out. much like the php5.0 OO functionality
was a fast moving target, much less so in more recent versions.
one day namespaced php code will be the norm, one that day Richard Lynch will either
announce his retirement (I hope not) or that he's decided to move over to the OO camp
(one man can only offer so much resistance ;-).
an issue I have with namespaces is that they aren't packages as you might fin d in other langs,
but you do seem to be tied into a particular development model (one namespace per file, namespaces
in their own file) ... something php has not really done before: upto now you have complete
control over how you split your code into files ... one big 'compiled' file is fine ... that is
something not yet possible if namespaces are used (this is the point your supposed to
STA the internals list for the brackets/no-brackets and multiple-namespaces-per-file
discussions)
I wouldn't bother trying to figure out an autoloading strategy for namespaces until
the namespaces api/functionality has settled properly, otherwise your likely to
have to rewrite the autoloader over and over.
essentially it boils down to replacing '::' with '/' to determine the path
from the namespace in your case - that is easy enough, your still stuck with
finding out whether your being asked to load a namespace, class, or function
(do namespaced functions even trigger an autoload, if not that obviously makes
things simpler. maybe the autoloader can just match the path as deep it can and
then load every file inside the determine path. e.g:
$c = 'MY::NS::Cls';
function __autoload($c)
{
$r = '/usr/var/myproj/lib`';
$p = explode('::', $c);
if (count($p) == 1) {
// load a class
return;
}
do {
$d = $p.'/'.join('/', $p);
if (is_dir()) {
recursivelyRequireMyPhpFiles($d);
return;
}
array_pop($p);
} while (count($p));
}
>
> -nathan
>
attached mail follows:
> Playing around with dev PHP 5.3 and namespaces
PHP 5.3 will have namespaces?
--
Richard Heyes
Employ me:
http://www.phpguru.org/cv
attached mail follows:
Jochem Maas wrote:
> essentially it boils down to replacing '::' with '/' to determine the path
> from the namespace in your case - that is easy enough, your still stuck
> with
> finding out whether your being asked to load a namespace, class, or
> function
> (do namespaced functions even trigger an autoload, if not that obviously
> makes
> things simpler. maybe the autoloader can just match the path as deep it
> can and
> then load every file inside the determine path. e.g:
From my testing I've found the autoload function is called for any
namespace related call, functions and constants.
Your idea for replacing '::' with '/' is good but I'd think it'll
interfere with the arithmetic operator '/'. I'm sure they must have
discussed such options.
Is this something I should bring up on the internals? I think it is an
issue, autoload not being able to know if it's class or namespace related.
However, I think the call for namespace functions and constants is good,
just need to know it's for namespaces... Gives you the opportunity to
load the missing files.
attached mail follows:
On Wed, Apr 2, 2008 at 12:25 PM, Richard Heyes <richardh
phpguru.org> wrote:
> Playing around with dev PHP 5.3 and namespaces
> >
>
> PHP 5.3 will have namespaces?
ya; that and late static binding are like the two headliners.
both oo btw ;)
-nathan
attached mail follows:
On Wed, Apr 2, 2008 at 12:44 PM, Nathan Nobbe <quickshiftin
gmail.com>
wrote:
> On Wed, Apr 2, 2008 at 12:25 PM, Richard Heyes <richardh
phpguru.org>
> wrote:
>
> > Playing around with dev PHP 5.3 and namespaces
> > >
> >
> > PHP 5.3 will have namespaces?
>
>
> ya; that and late static binding are like the two headliners.
>
> both oo btw ;)
>
err-um sorry for the noise; actually the namespaces work w/ functions as
well.
-nathan
attached mail follows:
> err-um sorry for the noise; actually the namespaces work w/ functions as
> well.
So not OO specific? Is there anything I can read that describes them?
--
Richard Heyes
Employ me:
http://www.phpguru.org/cv
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]