Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About doug

  • Rank
  1. Thanks. That did work! I sort of see why and also don't see why. I thought that RegExp was supposed to take a string and turn it into a regular expression. \d only has one interpretation in a regular expression - a digit. So I thought that was ok as is. In fact, I would have guessed that \\d+ meant "find a backslash, the letter d and a plus sign."But anyway, I'll just try to remember to escape all my backslashes in RegExp from now on.You are right, of course, about \-, but I tend to escape all my punctuation so I don't have to remember which has special meaning and which doesn't.Thanks!doug
  2. This truly is a simple regular expression question. :)I have a variable theTitle with the value: "Test Group A BTYZ311-1"And a variable courseCode with the value "BTYZ311".I want to see if theTitle contains courseCode followed by a dash followed by 1 or more digits.This is my test: var matchExp = new RegExp(courseCode + '\-\d+', "i");if (!matchExp.test(theTitle)) { // do something because theTitle doesn't seem to contain the courseCode plus dash + number} The problem is the .test() method always returns false, so there must be something wrong with my RegExp.Does anybody happen to see what that might be?Thanks,doug
  3. There is no one server-side JavaScript, but the basic idea is that it is the same language, with all the core JavaScript methods and properties: String, Date, Objects, prototyping, etc. In our case, it interacts with a native object-oriented server-side database so you can use extended methods to do things like create new users, new discussions and folders and other kinds of objects for storing in the database.Naturally server-side JS is not aware of the client, so, for example, there is no "document" object to work with. Similarly client-side JS is not aware of the server-side database.The server-side JS can dynamically generate web pages, similar to how PHP does it. And the generated pages might have client-side JS in them.It's an alternative to PHP in some sense. I prefer it to PHP because JavaScript is such a rich, flexible language and you don't have to deal with two languages for development. But unfortunately it is not standard at all, or that wide spread.But in our system it works very well. It's also compiled on the server side so it's very fast.doug
  4. I've been using JavaScript, both client-side and server-side, for years. I never noticed this before though. Here is a quick client-side example: <html><script>var a = new Object();a. b = 'testing';document.write(a.b);</script></html> The above page opens and runs without complaint in at least Safari and FireFox. The equivalent in my server-side JS also compiles without error and runs fine.But... notice the extra space after the period, before the property name, in the a. b = 'testing'; line. Why doesn't that space cause a problem?Just curious.doug
  5. Ah. Well, that explains it. Thanks.doug
  6. Thanks. file_get_contents() does work. I am still curious about the http_get() function though, described at http://jp2.php.net/manual/en/function.http-get.phpThanks,doug
  7. The following very trivial (I thought) http_get() test fails: <?php$body = http_get('http://www.nytimes.com');echo $body;?> The error returned is:Fatal error: Call to undefined function http_get() in /home/doug/public_html/inpac/tests/httpRequest1.php on line 3I found http_get in the online PHP manual. Is it not a global, standard function?Thanks,doug
  8. In this example from the book I'm reading: <?$im = ImageCreateTrueColor(256,60); for($x=0; $x<256; $x++) { ImageLine($im, $x, 0, $x, 19, $x); ImageLine($im, 255-$x, 20, 255-$x, 39, $x<<8); ImageLine($im, $x, 40, $x, 59, $x<<16); } header('Content-Type: image/png'); ImagePNG($im); ?> three color bars are drawn.I understand the calculations in the last parameters of ImageLine. They look like the 32 bit r,g,b,alpha (with anti-aliasing flag) values that would be returned from imageColorResolveAlpha.But why wasn't it necessary to call imageColorAllocateAlpha to begin with to establish the colors for the image? Are calls to imageColorAllocateAlpha only needed if overriding some automatic default table?If so, does that hold true for imageColorAllocate and imageColorResolve as well?This book (the O'Reilly book "Programming PHP 2nd Ed" is sure skimpy on details in a lot of places!doug
  9. In the book I'm reading there is the following example, which works. Let's say this is in button.php: <?php $font = 'times'; if (!$size) $size = 12; $im = ImageCreateFromPNG('button.png'); // calculate position of text $tsize = ImageTTFBBox($size,0,$font,$text); $dx = abs($tsize[2]-$tsize[0]); $dy = abs($tsize[5]-$tsize[3]); $x = ( ImageSx($im) - $dx ) / 2; $y = ( ImageSy($im) - $dy ) / 2 + $dy; // draw text $black = ImageColorAllocate($im,0,0,0); ImageTTFText($im, $size, 0, $x, $y, $black, $font, $text); header('Content-Type: image/png'); ImagePNG($im); ?> The text parameter is passed in the URL as follows:http://thedomain.com/button.php?text=the+buttonMy question is, why does this work? Why didn't I have to have a line:$text = $_GET['text'];in order to grab the parameter from the URL?Isn't it dangerous to allow variables to just be set like that in the URL?doug
  10. Thanks, I'll take a look at the Wikipedia article. doug
  11. I'm not about to actually attempt a project that requires large scaling, but was wondering, just in general, what sites with massive scaling (like hundreds of thousands or even millions of users) do to achieve that?I assume a large part of the problem is the database. At some point, if all your SQL requests are made to one database on one server things just get to busy with requests to serve well.Is one way this is handled by breaking things up into multiple databases, and serving different databases on different servers?Like consider user records. Instead of keeping all the users in one big database, do larger projects employ strategies such as keeping all A users in one database, the B users in another, etc?For something like a large forums server, instead of storing all the tables for the forum content and all the tables for users records in one database, is there an advantage to storing the forums content in one database and the user records in another database?I'm just curious about the practical limitations of a single database and when you should consider breaking it up into multiple databases.Thanks,doug
  12. In my PHP database experiments so far, I've been using MySQL. It's all worked fine. I use cPanel at my ISP to create databases, set up the connections in PHP and everything works ok.In the O'Reilly book I've been reading, "Programming PHP 2nd Ed", in the chapter on databases, the author first suggests using the PEAR DB abstraction layer for the purposes of portability.At the end of the chapter, he describes another abstraction layer, PDO (PHP Data Objects) and says it should be available "by the time you read this" and listed some benefits over PEAR DB.What do most PHP programmers do these days? Just make MySQL calls directly? Make use of PEAR DB? Make use of PDO? I know that Ruby on Rails always uses database abstraction layers for maximum portability, and the idea seems like a good one. But what is really done in common practice?Also, the author mentions that SQLite is bundled with PHP. Is there any reason to prefer using that over MySQL?What are you thoughts?Thanks,doug
  13. I've been going through the O'Reilly book "Programming PHP". In the section on object constructors, there seems to be a mistake and I wanted to get your opinions of it. The section says: A constructor is a function in the class called __construct(). Here’s aconstructor for the Person class: class Person { function __construct($name, $ag‘e) { $this->name = $name; $this->age = $age; } } PHP does not provide for an automatic chain of constructors; that is, if you instanti- ate an object of a derived class, only the constructor in the derived class i sautomati- cally called. For the constructor of the parent class to be called, the constructor in the derived class must explicitly call the constructor. In this example, the Employee class constructor calls the Person constructor: class Person { var $name, $address, $age; function Person($name, $address, $age) { $this->name = $name; $this->address = $address; $this->age = $age; } } class Employee extends Person { var $position, $salary; function Employee($name, $address, $age, $position, $salary) { $this->Person($name, $address, $age); $this->position = $position; $this->salary = $salary; } } But in the example, a function __construct() is nowhere to be found. Is this an error, or can a function the same name as the class itself be used instead of the function name __construct?Thanks,doug
  14. There also appears to be commercially available solutions for this, such as:http://www.sourceguardian.com/doug
  15. Thanks. That looks like one possible way to go. It seems to be a partial, and also out-dated solution (doesn't support PHP 5) and is not maintained any more. But it is useful to know that there has been some thought to this.doug
  • Create New...