php-general Digest 23 Nov 2010 15:23:27 -0000 Issue 7050
Topics (messages 309612 through 309637):
Re: Wordpress Page: How to add pagination?
309612 by: Steve Staples
Can't find existing file
309613 by: Dee Ayy
309614 by: Daniel P. Brown
309615 by: Daniel P. Brown
309616 by: Dee Ayy
309617 by: Daniel P. Brown
309630 by: Dee Ayy
309632 by: Daniel Brown
Re: Problem with functions and arrays...
309618 by: Jason Pruim
Procedural Autoloader?
309619 by: Jason Pruim
309621 by: David Harkness
309622 by: Daniel P. Brown
309623 by: Daniel P. Brown
309624 by: Nathan Nobbe
309626 by: Daniel P. Brown
309627 by: Peter Lind
309628 by: Daniel Brown
309629 by: Jason Pruim
309631 by: David Harkness
309633 by: Richard Quadling
309635 by: David Harkness
309637 by: Steve Staples
Eclipse Manual
309620 by: Ethan Rosenberg
309625 by: Lester Caine
rewriteTextLinks.php - make URLs in plain text clickable
309634 by: Yermo
309636 by: Andre Polykanine
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 ---
> perhaps you could just google wordpress pagination
>
> http://www.google.ca/#sclient=psy&hl=en&q=wordpress+pagination&aq=1&aqi=g4g-o1&aql=&oq=&gs_rfai=&pbx=1&fp=88df74f51cdeec4c
>
> --
>
> Bastien
>
> Cat, the other other white meat
>
Here, this may help:
http://lmgt4u.com/?q=wordpress+pagination
Steve
--- End Message ---
--- Begin Message ---
1)
Warning: getimagesize("./photos/HPR-130-260_HD-3070-1.jpg"): failed to
open stream: No such file or directory in ... on line ...
ls ./photos/HPR-130-260_HD-3070-1.jpg
./photos/HPR-130-260_HD-3070-1.jpg
ls "./photos/HPR-130-260_HD-3070-1.jpg"
./photos/HPR-130-260_HD-3070-1.jpg
2) Similarly...
Also trying
$cmd = 'cp '.$src.' '.$dst;
exec($cmd);
And some files failed to copy. I assumed it was due to spaces in the
name, so I double quoted them. For example:
cp: ./photos/Nozzle 130 Amp SS Alum 94-00994-06 220197.JPG: No such
file or directory
ls "./photos/Nozzle 130 Amp SS Alum 94-00994-06 220197.JPG" FAILS THOUGH
cp ./photos/Nozzle\ 130\ Amp\ SS\ Alum\ 94-00994-06\ 220197.JPG ... ALSO FAILS
Help.
--- End Message ---
--- Begin Message ---
On Mon, Nov 22, 2010 at 14:24, Dee Ayy <[email protected]> wrote:
> 1)
> Warning: getimagesize("./photos/HPR-130-260_HD-3070-1.jpg"): failed to
> open stream: No such file or directory in ... on line ...
>
> ls ./photos/HPR-130-260_HD-3070-1.jpg
> ./photos/HPR-130-260_HD-3070-1.jpg
>
> ls "./photos/HPR-130-260_HD-3070-1.jpg"
> ./photos/HPR-130-260_HD-3070-1.jpg
>
>
> 2) Similarly...
> Also trying
> $cmd = 'cp '.$src.' '.$dst;
> exec($cmd);
>
> And some files failed to copy. I assumed it was due to spaces in the
> name, so I double quoted them. For example:
> cp: ./photos/Nozzle 130 Amp SS Alum 94-00994-06 220197.JPG: No such
> file or directory
>
> ls "./photos/Nozzle 130 Amp SS Alum 94-00994-06 220197.JPG" FAILS THOUGH
>
> cp ./photos/Nozzle\ 130\ Amp\ SS\ Alum\ 94-00994-06\ 220197.JPG ... ALSO FAILS
>
> Help.
Well, I'm not the most brilliant man in the world, but it sounds -
based upon your very vague description - as though the file doesn't
exist.
--
</Daniel P. Brown>
Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
(866-) 725-4321
http://www.parasane.net/
--- End Message ---
--- Begin Message ---
On Mon, Nov 22, 2010 at 14:36, Dee Ayy <[email protected]> wrote:
> Thes two lines means that they exist by using quoted and unquoted commands:
> ls ./photos/HPR-130-260_HD-3070-1.jpg
> ./photos/HPR-130-260_HD-3070-1.jpg
>
> ls "./photos/HPR-130-260_HD-3070-1.jpg"
> ./photos/HPR-130-260_HD-3070-1.jpg
Please use Reply-All to reply back to the list.
Also, please note:
./photos/HPR-130-260_HD-3070-1.jpg != ./photos/Nozzle 130 Amp
SS Alum 94-00994-06 220197.JPG
--
</Daniel P. Brown>
Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
(866-) 725-4321
http://www.parasane.net/
--- End Message ---
--- Begin Message ---
There are 2 separate issues numbered 1) and 2).
#1 deals with getimagesize operating on definitely existing files
verified by "ls".
#2 deals with escaping spaces in the name of the file and using the
exec command, which an example was given for a different file name
than in #1.
--- End Message ---
--- Begin Message ---
On Mon, Nov 22, 2010 at 14:52, Dee Ayy <[email protected]> wrote:
> There are 2 separate issues numbered 1) and 2).
>
> #1 deals with getimagesize operating on definitely existing files
> verified by "ls".
>
> #2 deals with escaping spaces in the name of the file and using the
> exec command, which an example was given for a different file name
> than in #1.
It would be helpful to explain that, then, instead of just
throwing out numbered lists with generic information and the command
"Help." thrown in at the bottom.
Is the script being called located in the same folder as your
command's PWD in the #1 issue? If it's an include called by a script
in a different directory, it's not the same thing. Try a full path
instead of the leading dot. Preferably, if you don't want to use full
paths, and if they're in the same directory as the command you issued,
you'd be using:
<?php getimagesize(dirname(__FILE__).'/photos/HPR-130-260_HD-3070-1.jpg');
?>
For issue #2, it could be any number of things: (a) the file
really doesn't exist and the system wasn't lying to you after all; (b)
your code is to blame; (c) you're still in the wrong directory; (d)
you're not giving it the proper cAsE-sEnSiTiViTy; (e) you don't have
the right permissions to execute the command (unlikely, since you
indicate that some did copy); (f) you're running out of disk space;
(g) 'cp' isn't in your path (again unlikely, but all you indicated is
that it failed, so how are we to know?); (h) some other PEBKAC issue;
(i) et cetera.
(Hint: we need more details, not just, 'Computer broken. Help.' ;-P)
--
</Daniel P. Brown>
Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
(866-) 725-4321
http://www.parasane.net/
--- End Message ---
--- Begin Message ---
Hi Daniel,
Tell me if this isn't self explanatory:
************
cp ./photos/Nozzle\ 130\ Amp\ SS\ Alum\ 94-00994-06\ 220197.JPG
"./photossized/001196-220197-0.jpg"
cp: ./photos/Nozzle 130 Amp SS Alum 94-00994-06 220197.JPG: No such
file or directory
************
Thanks for trying. Usually coders can read the error line and some
folks like to see what you have done to attack the problem, hence the
original "ls" line. I could have omitted the original "Help" at the
bottom. I didn't think it would confuse anyone by adding it. And
maybe you haven't seen the "ls" command.
Solving issue #1: The getimagesize command wants filenames unquoted
and unescaped. Those quotes were an attempt to handle spaces in the
filename, but ended up introducing the error.
For issue #2, I think you meant "really does exist"; of course my code
is to blame; the script is in the same dir as the photos and
photossized dirs. Thats what "./aDir" means -- but remember that only
some are failing; cases are preserved; yes, unlikely; the disk has a
lot of space; cp is on the path because "some" work; Obviously it's a
PEBKAC issue, that's why I came to this php list, to get it pointed
out; etc.
Solving issue #2 exec (or rather the shell) wants spaces escaped. And
yes, some files were there, but the lookup table had single spaces
while the filename being compared had double spaces.
--- End Message ---
--- Begin Message ---
On Mon, Nov 22, 2010 at 16:54, Dee Ayy <[email protected]> wrote:
> Hi Daniel,
> Tell me if this isn't self explanatory:
> ************
> cp ./photos/Nozzle\ 130\ Amp\ SS\ Alum\ 94-00994-06\ 220197.JPG
> "./photossized/001196-220197-0.jpg"
> cp: ./photos/Nozzle 130 Amp SS Alum 94-00994-06 220197.JPG: No such
> file or directory
> ************
> Thanks for trying. Usually coders can read the error line and some
> folks like to see what you have done to attack the problem, hence the
> original "ls" line. I could have omitted the original "Help" at the
> bottom. I didn't think it would confuse anyone by adding it. And
> maybe you haven't seen the "ls" command.
I'm presuming you mean that I didn't see it in your email, and I'm
willing to leave it at that.
> Solving issue #1: The getimagesize command wants filenames unquoted
> and unescaped. Those quotes were an attempt to handle spaces in the
> filename, but ended up introducing the error.
That's correct. Functions like getimagesize() handle their own
slashing, et cetera.
> For issue #2, I think you meant "really does exist"; of course my code
> is to blame; the script is in the same dir as the photos and
> photossized dirs. Thats what "./aDir" means -- but remember that only
> some are failing; cases are preserved; yes, unlikely; the disk has a
> lot of space; cp is on the path because "some" work; Obviously it's a
> PEBKAC issue, that's why I came to this php list, to get it pointed
> out; etc.
No, I didn't, actually. I meant "really doesn't exist." If the
file really did exist at that location, it wouldn't be a problem.
That may not be THIS problem, but it is A problem.
> Solving issue #2 exec (or rather the shell) wants spaces escaped. And
> yes, some files were there, but the lookup table had single spaces
> while the filename being compared had double spaces.
Exactly. Interacting with the shell using backticks, exec(),
passthru(), et al, is passed verbatim to the command line configured
with the server's user:group CLI environment. Generally, when passing
arguments, you should escapeshellarg() the arguments. And because the
files were misnamed, that means they didn't exist. You knew which
files you wanted, and to you, it was simple.... but the computer
didn't know it, and when it looked for the files you wanted, they
didn't exist.
--
</Daniel P. Brown>
Network Infrastructure Manager
Documentation, Webmaster Teams
http://www.php.net/
--- End Message ---
--- Begin Message ---
On Nov 21, 2010, at 4:57 PM, Tamara Temple wrote:
On Nov 20, 2010, at 5:31 PM, Jason Pruim wrote:
<?PHP
function ddbYear($name, $message, $_POST, $option){
Maybe it's just me, but using the name of a global as a function
parameter just seems like a bad idea. Yes, you can do it. Should
you? I think not. Especially, as, you are passing it a scalar below
and treating it here like the global array.
It was there as a hold over from when I originally made the functions
which just had to deal with getting variables from the $_POST global.
//Make sure to post form start/stop OUTSIDE of this function...
//It's not meant to be a one size fits all function!
echo "NAME: " . $name . "<BR>";
echo "MESSAGE: " . $message . "<BR>";
echo "POST: " . $_POST . "<BR>";
echo "OPTION: " . $option . "<BR>";
$sticky = '';
if(isset($_POST['submit'])) {
Check the error messages -- since you're passing in $startYear as a
scalar below, you shouldn't be able to access $_POST as an
associative array.
ini_set("display_errors", 1);
error_reporting(-1);
were both on and were not complaining about anything...
$sticky = $_POST["{$name}"];
echo "STICKY: " . $sticky;
}
//echo "OPTION: ";
//print_r($option);
echo <<<HTML
<select name="{$name}">
<option value="0">{$message}</option>
HTML;
foreach ($option as $key => $value){
if($key == $sticky) {
echo '<option value="' . $key .'" selected>' . $value . '</option>';
}else{
echo '<option value="' . $key .'">' . $value . '</option>';
}
}
echo <<<HTML
</select>
HTML;
unset($value);
return;
}
?>
One for Month, Day & Year... All the same exact code... When I get
brave I'll combine it into 1 functions :)
Now... What it's trying to do.. It's on a "update" form on my
website. Basically pulls the info from the database and displays it
in the form again so it can be edited and resubmitted...
As I'm sure you can tell from the function it checks to see if the
a value has been selected in the drop down box and if it has then
set the drop down box to that value.
I call the function like this:
<?PHP
$startYear = date("Y", $row['startdate']); //Actual DBValue:
1265000400
You're setting $startYear as a scalar value here.
$optionYear = array("2010" => "2010", "2011" => "2011", "2012" =>
"2012", "2013" => "2013", "2014" => "2014");
ddbYear("startYear", "Select Year", $startYear, $optionYear);
And passing it in to the $_POST variable in your function. Then you
treat the $_POST variable as an associative array (seemingly much
like the global $_POST array).
?>
The output I'm getting is:
THESE ARE THE ACTUAL UNPROCESSED (OTHER THEN SEPARATING) VALUES
FROM THE DATABASE
startmonth: 2
startday: 1
startYear: 2010
endmonth: 11
endDay: 30
endYear: 1999
THESE ARE THE VALUES INSIDE THE FUNCTION
NAME: startYear
MESSAGE: Select Year
POST: 2010
OPTION: Array
STICKY: 2
Now... The problem is that $sticky get set to "2" instead of
"2010"... But I can't figure out why...
Anyone have any ideas?
And just incase I didn't provide enough info here's a link that
shows it happening:
HTTP://jason.pruimphotography.com/dev/cms2/events/update_form.php?id=62
Again, I will reiterate that taking the name of a global variable
and using it as a parameter in a function is a bad idea. It can be
done, and my in some cases have some uses, but I don't think the way
you're using it is a good idea, and looks wrong to me as well.
Turns out it was a conflict with the $_POST global.. Or my
misunderstanding inside the functions... I changed that to another
name and now it works fine...
Thanks Tamara!
--- End Message ---
--- Begin Message ---
Hey Everyone!
Fresh off my problem with functions and arrays I come across something
that I can't seem to find currently... The autoloader function that is
in PHP 5+ works on classes... But I'm not finding anything that would
do the same thing on the procedural end... Such as I have a folder
typically called includes in my projects where I place all my function
files... I would LOVE to use the autoloader to be able to just load
them on demand... But in my quick searching/thinking I haven't found
away too... So I thought I would see if anyone had invented that wheel
yet before I go and try and do it my self :)
I may also have a misunderstanding of how it is supposed to work since
I don't truly understand OOP I've always done procedural...
Any help on this one would be greatly appreciated it! :)
Jason Pruim
--- End Message ---
--- Begin Message ---
On Mon, Nov 22, 2010 at 12:37 PM, Jason Pruim <[email protected]>wrote:
> The autoloader function that is in PHP 5+ works on classes... But I'm not
> finding anything that would do the same thing on the procedural end.
>
I'll start by explaining how it typically works with classes. The Zend
Framework is a popular web/application class library. It organizes its
classes into packages much like Java, Python, and other languages, where
each package is a folder that contains other packages and classes. In Java,
packages are a language feature so you have java.util.List which is the
fully-qualified name of the List class that lives in the java.util package.
PHP doesn't have the notion of packages, though 5.3 introduced namespaces
which are similar but different. The autoloader function in PHP takes a
class name and locates the file that should define it. In Zend this is done
by separating the folder names by underscores, e.g. Zend_Http_Request. The
autoloader splits the class name on underscores and looks in registered
folders for a folder named Zend, and inside that for another folder named
Http, and inside that for a file named Request.php. Zend's autoloader class
provides more features such as aliases for folders so "ZF" would map to
"Zend".
The above is based on the convention of having one class per file. I doubt
you'll be doing that for functions, so even if PHP had an autoloading
mechanism for functions, you'd still need a way to map from function name to
file name. I suppose you could do the same as above but drop the final name
element when looking for the file. For example, the function math_trig_cos()
would map to the function cos() defined in "math/trig.php".
But it's all academic because PHP does not support such a feature. You could
probably create a PHP extension if you wanna roll up your sleeves and get
dirty in C. :)
David
--- End Message ---
--- Begin Message ---
On Mon, Nov 22, 2010 at 15:37, Jason Pruim <[email protected]> wrote:
> Hey Everyone!
>
> Fresh off my problem with functions and arrays I come across something that
> I can't seem to find currently... The autoloader function that is in PHP 5+
> works on classes... But I'm not finding anything that would do the same
> thing on the procedural end... Such as I have a folder typically called
> includes in my projects where I place all my function files... I would LOVE
> to use the autoloader to be able to just load them on demand... But in my
> quick searching/thinking I haven't found away too... So I thought I would
> see if anyone had invented that wheel yet before I go and try and do it my
> self :)
>
> I may also have a misunderstanding of how it is supposed to work since I
> don't truly understand OOP I've always done procedural...
>
> Any help on this one would be greatly appreciated it! :)
There's no such thing, Prune. Autoloaders are for classes, and
the only way you could have it work for functions would be to catch
the error in the core and handle it at a lower level than your scripts
(modified core or extension), because the error generated for an
undefined function isn't a catchable fatal. Alternatively, you
*could* write a function wrapper that utilizes function_exists() and
the like, then rewrite all of your code to use that wrapper.... but
how much sense does that make? ;-P
--
</Daniel P. Brown>
Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
(866-) 725-4321
http://www.parasane.net/
--- End Message ---
--- Begin Message ---
On Mon, Nov 22, 2010 at 15:37, Jason Pruim <[email protected]> wrote:
> Hey Everyone!
>
> Fresh off my problem with functions and arrays I come across something that
> I can't seem to find currently... The autoloader function that is in PHP 5+
> works on classes... But I'm not finding anything that would do the same
> thing on the procedural end... Such as I have a folder typically called
> includes in my projects where I place all my function files... I would LOVE
> to use the autoloader to be able to just load them on demand... But in my
> quick searching/thinking I haven't found away too... So I thought I would
> see if anyone had invented that wheel yet before I go and try and do it my
> self :)
>
> I may also have a misunderstanding of how it is supposed to work since I
> don't truly understand OOP I've always done procedural...
>
> Any help on this one would be greatly appreciated it! :)
There's no such thing, Prune. Autoloaders are for classes, and
the only way you could have it work for functions would be to catch
the error in the core and handle it at a lower level than your scripts
(modified core or extension), because the error generated for an
undefined function isn't a catchable fatal. Alternatively, you
*could* write a function wrapper that utilizes function_exists() and
the like, then rewrite all of your code to use that wrapper.... but
how much sense does that make? ;-P
--
</Daniel P. Brown>
Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
(866-) 725-4321
http://www.parasane.net/
--- End Message ---
--- Begin Message ---
On Mon, Nov 22, 2010 at 2:24 PM, Daniel P. Brown
<[email protected]>wrote:
> On Mon, Nov 22, 2010 at 15:37, Jason Pruim <[email protected]>
> wrote:
> > Hey Everyone!
> >
> > Fresh off my problem with functions and arrays I come across something
> that
> > I can't seem to find currently... The autoloader function that is in PHP
> 5+
> > works on classes... But I'm not finding anything that would do the same
> > thing on the procedural end... Such as I have a folder typically called
> > includes in my projects where I place all my function files... I would
> LOVE
> > to use the autoloader to be able to just load them on demand... But in my
> > quick searching/thinking I haven't found away too... So I thought I would
> > see if anyone had invented that wheel yet before I go and try and do it
> my
> > self :)
> >
> > I may also have a misunderstanding of how it is supposed to work since I
> > don't truly understand OOP I've always done procedural...
> >
> > Any help on this one would be greatly appreciated it! :)
>
> There's no such thing, Prune. Autoloaders are for classes, and
> the only way you could have it work for functions would be to catch
> the error in the core and handle it at a lower level than your scripts
> (modified core or extension), because the error generated for an
> undefined function isn't a catchable fatal. Alternatively, you
> *could* write a function wrapper that utilizes function_exists() and
> the like, then rewrite all of your code to use that wrapper.... but
> how much sense does that make? ;-P
Shrug, if you want to really be dirty about it, you could just put a 'class'
atop each file of functions.
<?php
class IWishTheseFunctionsWereOOInstead {} // :P
function firstProceeduralFunc() {
// ..
}
?>
-nathan
--- End Message ---
--- Begin Message ---
On Mon, Nov 22, 2010 at 16:31, Nathan Nobbe <[email protected]> wrote:
>
> Shrug, if you want to really be dirty about it, you could just put a 'class'
> atop each file of functions.
> <?php
> class IWishTheseFunctionsWereOOInstead {} // :P
> function firstProceeduralFunc() {
> // ..
> }
> ?>
That's not going to be economical or allow him to autoload,
though, because the autoloader is called when the class is
instantiated. Prune could instantiate it thusly:
<?php
$foo = new IWishTheseFunctionsWereOOInstead();
firstProceeduralFunc(); // [sic]
?>
.... but it would be just as simple to do:
<?php
require dirname(__FILE__).'/includes/function.php';
firstProceeduralFunc(); // [sic, again]
?>
--
</Daniel P. Brown>
Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
(866-) 725-4321
http://www.parasane.net/
--- End Message ---
--- Begin Message ---
On 22 November 2010 22:40, Daniel P. Brown <[email protected]> wrote:
> On Mon, Nov 22, 2010 at 16:31, Nathan Nobbe <[email protected]> wrote:
>>
>> Shrug, if you want to really be dirty about it, you could just put a 'class'
>> atop each file of functions.
>> <?php
>> class IWishTheseFunctionsWereOOInstead {} // :P
>> function firstProceeduralFunc() {
>> // ..
>> }
>> ?>
>
> That's not going to be economical or allow him to autoload,
> though, because the autoloader is called when the class is
> instantiated.
Not to mention that it has nothing to do with a procedural autoloader.
Autoloading takes place if you try to instantiate an object of a class
that PHP doesn't know about (yet). There is no such thing for
functions. Either refactor your code so you don't have this problem
(The Way To Go [tm]) or make an extension. End of discussion.
Regards
Peter
--
<hype>
WWW: plphp.dk / plind.dk
LinkedIn: plind
BeWelcome/Couchsurfing: Fake51
Twitter: kafe15
</hype>
--- End Message ---
--- Begin Message ---
On Mon, Nov 22, 2010 at 16:47, Peter Lind <[email protected]> wrote:
>
> Not to mention that it has nothing to do with a procedural autoloader.
> Autoloading takes place if you try to instantiate an object of a class
> that PHP doesn't know about (yet). There is no such thing for
> functions. Either refactor your code so you don't have this problem
> (The Way To Go [tm]) or make an extension. End of discussion.
Yeah, but I'm not yet done talking about it, so I may revisit it
again in a few years when everyone's forgotten all about this thread.
--
</Daniel P. Brown>
Network Infrastructure Manager
Documentation, Webmaster Teams
http://www.php.net/
--- End Message ---
--- Begin Message ---
On Nov 22, 2010, at 4:24 PM, Daniel P. Brown wrote:
On Mon, Nov 22, 2010 at 15:37, Jason Pruim
<[email protected]> wrote:
Hey Everyone!
Fresh off my problem with functions and arrays I come across
something that
I can't seem to find currently... The autoloader function that is
in PHP 5+
works on classes... But I'm not finding anything that would do the
same
thing on the procedural end... Such as I have a folder typically
called
includes in my projects where I place all my function files... I
would LOVE
to use the autoloader to be able to just load them on demand... But
in my
quick searching/thinking I haven't found away too... So I thought I
would
see if anyone had invented that wheel yet before I go and try and
do it my
self :)
I may also have a misunderstanding of how it is supposed to work
since I
don't truly understand OOP I've always done procedural...
Any help on this one would be greatly appreciated it! :)
There's no such thing, Prune. Autoloaders are for classes, and
the only way you could have it work for functions would be to catch
the error in the core and handle it at a lower level than your scripts
(modified core or extension), because the error generated for an
undefined function isn't a catchable fatal. Alternatively, you
*could* write a function wrapper that utilizes function_exists() and
the like, then rewrite all of your code to use that wrapper.... but
how much sense does that make? ;-P
How much sense do I ever make? :P
Maybe it's time to get a book on OOP and start learning the concept..
Or find a better way to load my functions so I don't have to have 1
huge functions file or tons of includes if I have them all separate...
Or maybe I can just bastardize classes enough to make something work :P
I think most of my functions border on classes anyway... Off to google
to see if I'm right! :)
--- End Message ---
--- Begin Message ---
The simplest solution would be to move those functions into static methods
of classes. Place one class in each file to organize your functions and use
an autoloader to load the classes. You don't need to instantiate the class
to use the autoloader--just reference it statically:
// library/Math.php
class Math {
const PI = 3.14159;
public static function sin($radians) {...}
}
...
$x = $radius * Math::cos(Math::PI * 0.5);
David
--- End Message ---
--- Begin Message ---
On 22 November 2010 22:02, David Harkness <[email protected]> wrote:
> The simplest solution would be to move those functions into static methods
> of classes. Place one class in each file to organize your functions and use
> an autoloader to load the classes. You don't need to instantiate the class
> to use the autoloader--just reference it statically:
>
> // library/Math.php
> class Math {
> const PI = 3.14159;
>
> public static function sin($radians) {...}
> }
>
> ...
>
> $x = $radius * Math::cos(Math::PI * 0.5);
>
> David
>
Would it be overboard to use a namespace? Aren't namespaces handled by
the autoloader? If not autoload(), how about spl_autoloading?
--
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY
--- End Message ---
--- Begin Message ---
On Mon, Nov 22, 2010 at 3:05 PM, Richard Quadling <[email protected]>wrote:
> Would it be overboard to use a namespace? Aren't namespaces handled by
> the autoloader? If not autoload(), how about spl_autoloading?
>
Autoloading is for determining the path and filename where a named item is
defined. Namespaces only give you the path. Even with namespaces, you'd
still need to require the files that contain the functions. Plus you'd also
need to use the namespace everywhere you use the function because you cannot
alias functions--only classes. :(
David
--- End Message ---
--- Begin Message ---
On Mon, 2010-11-22 at 15:26 -0800, David Harkness wrote:
> On Mon, Nov 22, 2010 at 3:05 PM, Richard Quadling <[email protected]>wrote:
>
> > Would it be overboard to use a namespace? Aren't namespaces handled by
> > the autoloader? If not autoload(), how about spl_autoloading?
> >
>
> Autoloading is for determining the path and filename where a named item is
> defined. Namespaces only give you the path. Even with namespaces, you'd
> still need to require the files that contain the functions. Plus you'd also
> need to use the namespace everywhere you use the function because you cannot
> alias functions--only classes. :(
>
> David
can I maybe make a suggestion? If I have been following this
correctly, it seems as if the OP has a bunch of "non specific class"
functions, that he doesn't want in 1 big gigantic file, and include that
one huge file ALL the time... what if the OP put some naming
conventions into the function names, and then did some kind of error
trapping on the function calls, and if the function does not exist (yet)
then call some other function to rip apart the name of the function that
was called, and then include that "file"? I am just offering some kind
of hypothetical solution, and off the top of my head can't think exactly
how it could be accomplished.
you could always wrap all your "non class"/"custom" functions in a
function...
function checkFunction($file, $function, $args)
{
$filename = "./function_{$file}.php";
if(file_exists($filename))
{
include_once($filename);
}
else
{
return 'function file not exist';
}
if(function_exists($file .'_'. $function))
{
return call_user_func_array($file .'_'. $function, $args);
}
else
{
return "Function: {$function}() does not exist";
}
return 'Fire and brimstone coming down from the skies! Rivers and seas
boiling! Forty years of darkness! Earthquakes, volcanoes... The dead
rising from the grave! Human sacrifice, dogs and cats living together...
mass hysteria!!';
}
$temp = checkFunction('test', 'somefunction', array('var1', 'var2'));
then create the functions file- functions_test.php that holds all the
functions you would "group" together...
function test_somefunction($var1, $var2, $var3 = '')
{
return $var1 .' - '. $var2;
}
This is just a thought, and yeah, it would require some rewrites, and
some forward thinking... but could solve your issue... maybe
steve
--- End Message ---
--- Begin Message ---
Dear list -
Does anyone have a URL for the manual for Eclipse/PHP.
Ethan
MySQL 5.1 PHP 5 Linux [Debian (sid)]
--- End Message ---
--- Begin Message ---
Ethan Rosenberg wrote:
Dear list -
Does anyone have a URL for the manual for Eclipse/PHP.
Depends which one you are looking for
PHPEclipse is on their site
http://www.phpeclipse.com/wiki/General/PHPEclipseFAQ is a good starting point.
If you must use PDT, then http://wiki.eclipse.org/index.php/PDT
--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php
--- End Message ---
--- Begin Message ---
I'm posting this in the hopes that it will be of some use to someone.
I've put together a little regex function for finding and transforming
links in blocks of plain text into clickable links while applying some
heuristics to handle the more common edge cases.
Unlike so many solutions I've found online this one handles more edge
cases including periods and commas at the end, surrounding parentheses,
trailing periods on only the domain part, etc. etc.
http://formvista.com/fv-b-12-170/rewriteTextLinks-----a-function-to-make-links-in-blocks-of-text--quot-clickable-quot-.html
---------------------------------------------------------------
Yermo Lamers DTLink, LLC
Software Developer http://www.dtlink.com
http://miles-by-motorcycle.com For Motorcycle Travellers
http://formvista.com Entrepreneurs CMS and Business Platform
---------------------------------------------------------------
--- End Message ---
--- Begin Message ---
Hello Yermo,
thanks a lot! I will try this on my project (http://oire.org/) and
I'll inform you if I modify it somehow.
--
With best regards from Ukraine,
Andre
Skype: Francophile
Twitter: http://twitter.com/m_elensule
Facebook: http://facebook.com/menelion
----- Original message -----
From: Yermo <[email protected]>
To: [email protected] <[email protected]>
Date: Tuesday, November 23, 2010, 1:04:19 AM
Subject: [PHP] rewriteTextLinks.php - make URLs in plain text clickable
I'm posting this in the hopes that it will be of some use to someone.
I've put together a little regex function for finding and transforming
links in blocks of plain text into clickable links while applying some
heuristics to handle the more common edge cases.
Unlike so many solutions I've found online this one handles more edge
cases including periods and commas at the end, surrounding parentheses,
trailing periods on only the domain part, etc. etc.
http://formvista.com/fv-b-12-170/rewriteTextLinks-----a-function-to-make-links-in-blocks-of-text--quot-clickable-quot-.html
---------------------------------------------------------------
Yermo Lamers DTLink, LLC
Software Developer http://www.dtlink.com
http://miles-by-motorcycle.com For Motorcycle Travellers
http://formvista.com Entrepreneurs CMS and Business Platform
---------------------------------------------------------------
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---