Re: [PHP] how do I use and lt with eval()?
Stefan Rusterholz [EMAIL PROTECTED] wrote in message 001001c162af$1fd842f0$3c01a8c0@quasimodo">news:001001c162af$1fd842f0$3c01a8c0@quasimodo... [...] As you see, for PHP is some HTML-Code in the php-code-zone. To avoid this, do it that way: ?php function somefunc($text,$n) { for($i=0;$i$n;$i++){ echo $text; } } $string='xxx ?php somefunc(yyy,3); ? zzz'; eval(?$string); ? Pay attention to the trailing ? in eval. That causes php to change to HTML-Mode within the eval'd code. Yes, thanks - it works now. I can see that you have to exit php code mode before you encounter HTML 'xxx'. Then you enter php mode, run somefunc() and exit again so you can deal with HTML 'zzz'. But that leaves you outside php mode, right? If the next thing after eval() is more php code, don't you have to enter php mode again like this: eval(?$string?php ); echo hello; I tried it with and without ?php appended to $string. The hello always works. Why? Does eval() automatically put you back into php mode? Stated another way, you said that this $string='xxx ?php somefunc(yyy,3); ? zzz'; eval(?$string); echo hello; is equivalent to: ?xxx ?php somefunc(yyy,3); ? zzz echo hello; So why doesn't it treat echo hello as HTML code in pass-through mode? In fact, it just prints hello. -- John A. Grant * I speak only for myself * (remove 'z' to reply) Radiation Geophysics, Geological Survey of Canada, Ottawa If you followup, please do NOT e-mail me a copy: I will read it here -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] parsing a string
Mike Eheler [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Beyond that, why not keep it conforming to HTML, and use an IMG tag, for example: This is some text img src=name.jpg alt=Alt Text processat=server. That way if you need to view the page as-is in a browser or whatever, it'd still look fine.. go grab yourself some good free html parser code, and analyse the options. If processat=server then do your thing, and re-write the img tag. :) I think I want something more simple. The idea is to let the machine do all of the dirty work, not just in looking up the image size, but also formatting the output. For example, I'm already using functions like: emitlink(http://www.microsoft.com,Microsoft;); so I will have a similar function: emitimg(bird.gif,this is a bird); that will do all of the IMG stuff, not just some of it. -- John A. Grant * I speak only for myself * (remove 'z' to reply) Radiation Geophysics, Geological Survey of Canada, Ottawa If you followup, please do NOT e-mail me a copy: I will read it here -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] parsing a string
Dl Neil [EMAIL PROTECTED] wrote in message 042101c157f6$4cd9fb90$c014100a@jrbrown">news:042101c157f6$4cd9fb90$c014100a@jrbrown... Two inter-dependent problems: 1 a means of identifying a cipher within the text 2 a means of replacing the cipher with HTML code Succinctly stated. space+bird.gifthis is a bird This is a possibility, but it requires a bit trickier code to recognize split it. I was hoping for something easier to identify and parse, so maybe: #bird.gif|some text# That should be easy enough to find explode() -- John A. Grant * I speak only for myself * (remove 'z' to reply) Radiation Geophysics, Geological Survey of Canada, Ottawa If you followup, please do NOT e-mail me a copy: I will read it here -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: parsing a string
Yz James [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hey John, something like this might work: ? $string = This is a string with an embedded image [bird.gif,this is a bird]; $string = preg_replace(/\[(.*?\.)(gif|jpg),(.*?)\]/i, img src=\\\1\\2\ alt=\\\3\, $string); echo $string; ? Great!. I love it when I see stuff like this written by someone who knows regex better than I. The ability to insert the pieces that are recognized/extracted via \1, \2 is pretty cool. Thanks. -- John A. Grant * I speak only for myself * (remove 'z' to reply) Radiation Geophysics, Geological Survey of Canada, Ottawa If you followup, please do NOT e-mail me a copy: I will read it here -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] how do I use and lt with eval()?
I'm not having an easy time understanding the discussion in the doc for eval(). I want to read this string from a file: xxx ?php somefunc(yyy,3); ? zzz and then run it. I tried this code: ?php function somefunc($text,$n) { for($i=0;$i$n;$i++){ echo $text; } } $string='xxx ?php somefunc(yyy,3); ? zzz'; eval($string); ? but I get Parse error: parse error in eval.php(11) : eval()'d code on line 1 Do I have to use lt; and gt; in place of ? I tried several combinations, but I still get the same error. -- John A. Grant * I speak only for myself * (remove 'z' to reply) Radiation Geophysics, Geological Survey of Canada, Ottawa If you followup, please do NOT e-mail me a copy: I will read it here -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] how to pass true/false or no argument
I've written several functions with optional string parameters. They work fine. But I've never written one that accepts an optional bool parameter and I'm now confused. I would like to have this: somefunction(hello); somefunction(hello,false); somefunction(hello,true); function somefunction($text,$xxx=) { if($xxx){ $xxx parameter was passed as true or false }else{ $xxx parameter was not passed } } Which is correct for the default initialization of $xxx: $xxx=false; $xxx=null; $xxx=; How do I distinguish between false and $xxx parameter not passed? Do I use isset()? Do I use ===? Thanks. -- John A. Grant * I speak only for myself * (remove 'z' to reply) Radiation Geophysics, Geological Survey of Canada, Ottawa If you followup, please do NOT e-mail me a copy: I will read it here -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: how to pass true/false or no argument
John A. Grant [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... [...] How do I distinguish between false and $xxx parameter not passed? Do I use isset()? Do I use ===? Well, I guess I should have done some homework first. This code seems to work fine: function somefunction($text,$xxx=null) { if(isset($xxx)){ echo $xxx ? true : false; }else{ echo null; } echo \n; } somefunction(hello); somefunction(hello,true); somefunction(hello,false); It prints: null true false which is what I want. -- John A. Grant * I speak only for myself * (remove 'z' to reply) Radiation Geophysics, Geological Survey of Canada, Ottawa If you followup, please do NOT e-mail me a copy: I will read it here -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] how to recognize local or server execution?
Dl Neil [EMAIL PROTECTED] wrote in message 0a4e01c15e72$c47db560$a516100a@jrbrown">news:0a4e01c15e72$c47db560$a516100a@jrbrown... Thanks for the idea. I have just resurrected and had another play with my 'testbench.php', running it from both IE/Apache and in a DOS box. It includes the following code: [...] Thanks (also thanks to the others for the useful comments ideas). I don't have $HTTP_SERVER_VARS[SERVER_NAME] or $GLOBALS[SERVER_ADDR] or $SERVER_SOFTWARE probably because my server is netscape (nsapi?). They are all blank. Yes I declared them 'global'. I ended up with these functions which seem to do the trick, at least for my server and NT. function isonserver() { global $PHP_SELF,$argc; return $argc==0 isset($PHP_SELF) $PHP_SELF; } function getpagename() { global $PHP_SELF,$argv; return basename(isonserver() ? $PHP_SELF : $argv[0]); } function getlinedelimiter() { return isonserver() ? \n : \r\n; } The pagename is critical to my site, because the code needs the page name to recognize certain suffixes and 'special page names. Perhaps it is only sufficient to test for $PHP_SELF and not $argc, but I threw in $argc==0 anyway. -- John A. Grant * I speak only for myself * (remove 'z' to reply) Radiation Geophysics, Geological Survey of Canada, Ottawa If you followup, please do NOT e-mail me a copy: I will read it here -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Re: is there a commandline php.exe interpreter?
Jim Lucas [EMAIL PROTECTED] wrote in message 022901c15dbd$76a34c20$[EMAIL PROTECTED]">news:022901c15dbd$76a34c20$[EMAIL PROTECTED]... try this ? system(php.exe filename, $output); echo $output; ? make sure you put the correct paths to the .exe and file otherwise it will think that it is realtive to where you are in the file system. Thanks Jim (and to DNeil and David). Short answer: I got it working ok Long answer: I guess I wasn't very clear... Let me explain... Up until now I have been creating php pages to run on our departmental php-enabled server. Now I want to run php locally on my NT system to generate *.html pages from those *.php pages (to include the *.html pages on a CD). I started to run php406_installer.exe on my system and it started asking questions about my server (upload and temporary directories). I figured the package was just for use with a server on my system so I cancelled the install. I had another go at it and told it no server and it installed fine. Then I had a look at the install directory. Wow!! It's just a couple of files - very compact. I thought it might be like a Perl install with tonnes of stuff. Anyway, I tried it out and it works just fine: php -q xxx.php xxx.html php -q yyy.php yyy.html So I can now generate the *.html files from *.php. Then I run a batch editor on them to replace links to *.php with links to corresponding *.html files. Thanks. -- John A. Grant * I speak only for myself * (remove 'z' to reply) Radiation Geophysics, Geological Survey of Canada, Ottawa If you followup, please do NOT e-mail me a copy: I will read it here -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] how to recognize local or server execution?
I have an xxx.php page that runs on my Unix server. I also run php.exe on my NT box to generate the corresponding xxx.html file like this: c:\ php -q xxx.php xxx.html The xxx.php file contains stuff like this: print hello\n; That means stdout from the server and the xxx.html file both contain \n. I would like the xxx.html file to contain \r\n so it can be viewed/edited with notepad. Yes, notepad and \r\n both suck, but that's another story... So I guess I would like my code to look like this: if(running php.exe on my NT box){ $delimiter=\r\n; }else{ $delimiter=\n; } and then my code looks like: print hello$delimiter; How can I do this? -- John A. Grant * I speak only for myself * (remove 'z' to reply) Radiation Geophysics, Geological Survey of Canada, Ottawa If you followup, please do NOT e-mail me a copy: I will read it here -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] = 0 and = 0
Rasmus Lerdorf [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... The integer 0 is equal to False, but not Null. Not quite true. 0 evaluates to false. They are not equal. Try this: [...] So be careful and try to think of 0 and false as distinct and separate entities and you will avoid coding mistakes like this. Is this seen as a strength or a weakness of PHP.? In C(++), direct comparisons to true/false are discouraged. In other words, instead of this: bool x; if(x==true) ... if(x==false) ... itt's always considered better to do this: if(x) ... if(!x) ... But PHP seems to require a direct comparison with false in certain situations. Are there any cases where you need to do a direct comparison with true? Are you coming to Ottawa in the future? -- John A. Grant * I speak only for myself * (remove 'z' to reply) Radiation Geophysics, Geological Survey of Canada, Ottawa If you followup, please do NOT e-mail me a copy: I will read it here -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: is there a commandline php.exe interpreter?
John A. Grant [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I've installed ActivePerl, which gives me a way to run .pl files, i.e. : c:\ perl someprogram.pl Does the Win32 php installation give me a command-line interpreter like that? [...] No replies. I guess not, just server-based... :( -- John A. Grant * I speak only for myself * (remove 'z' to reply) Radiation Geophysics, Geological Survey of Canada, Ottawa If you followup, please do NOT e-mail me a copy: I will read it here -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: redirecting the browser
Ozgur Demirtas [EMAIL PROTECTED] wrote in message 001a01c15c57$ce6fad20$ea0d198a@Jackhammer">news:001a01c15c57$ce6fad20$ea0d198a@Jackhammer... Hi all, I have a PHP script and at one point of the script I am trying to redirect my browser to a certaion page. I can't seem to find an easy way of doing this. header() call is so much of a problem. There is no such function like redirect(...) as in ASP? PS: I am using PHP version 3.09 as an Apache module on Solaris. Discussion: http://www.chron.com/cs/CDA/story.hts/tech/735399 Solution: http://www.builder.com/Authoring/Tagmania/011000/index.html The latter solution is very good because it covers all of the bases. -- John A. Grant * I speak only for myself * (remove 'z' to reply) Radiation Geophysics, Geological Survey of Canada, Ottawa If you followup, please do NOT e-mail me a copy: I will read it here -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] how do i give optional arguments to functions??
Chris Bailey [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Check out the manual section on default parameters... But the basics are: function top($image = null) { if ($image) Shouldn't that be: function top($image=null) if ($image) -- John A. Grant * I speak only for myself * (remove 'z' to reply) Radiation Geophysics, Geological Survey of Canada, Ottawa If you followup, please do NOT e-mail me a copy: I will read it here -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] is there a commandline php.exe interpreter?
I've installed ActivePerl, which gives me a way to run .pl files, i.e. : c:\ perl someprogram.pl Does the Win32 php installation give me a command-line interpreter like that? Here's why I'm asking. I have a set of pages that I want to convert to php, but I will also need to drop those pages onto a CD too. I suppose I could view each page from the server and 'save as HTML' locally, but I was thinking that I might be able to run a php interpreter on the *.php pages and generate corresponding *.html pages in batch mode as follows: c:\ php index.php index.html c:\ php about.php about.html etc. Then I would have to run a batch search/replace program on the *.html files to change all links to *.php pages to link to the newly-generated *.html pages. Is there anything like that in the win32 install package or just configure a web server? I started to install it, but it looked like it was going to just install server stuff, so I cancelled it. -- John A. Grant * I speak only for myself * (remove 'z' to reply) Radiation Geophysics, Geological Survey of Canada, Ottawa If you followup, please do NOT e-mail me a copy: I will read it here -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] view *.php pages locally on NT?
Reductor [EMAIL PROTECTED] wrote in message news:003a01c15654$4d89c280$eb00a8c0@mum... How do I view these *.php pages locally. I'm using Windows NT and I have both MSIE (preferred) Netscape. http://miniserver.wxs.org Is the URL to the Miniserver Site Its a great little web server, havn't had a problem, also the easiest to setup, and you can install perl, php, and run isapi pages easilyalso just install mysql, set it up in php, and use mysql :D Thanks (also to Martin for his similar idea). I will look into that server. I've installed ActivePerl, which gives me a way to run .pl files, i.e. : c:\ perl someprogram.pl Does the php installation give me a command-line interpreter like that? Here's why I'm asking. I have a set of pages that I want to convert to php, but I will also need to drop those pages onto a CD too. I supposed I could view each page from the server and 'save as HTML' locally, but I was thinking that I might be able to run a php interpreter on the *.php pages and generate corresponding *.html pages in batch mode as follows: c:\ php index.php index.html c:\ php about.php about.html etc. and then run a batch search/replace program on the *.html files to change all links to .php pages to link to the newly-generated pages. Is there anything like that or does the install package just configure a web server? -- John A. Grant * I speak only for myself * (remove 'z' to reply) Radiation Geophysics, Geological Survey of Canada, Ottawa If you followup, please do NOT e-mail me a copy: I will read it here -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] parsing a string
I'm reading some HTML text from a file and echoing it to stdout. The HTML text contains IMG but I would rather have the server do the work of looking up the image size. I know how to lookup the image size with getimagesize(). My problem is in coming up with a good format for embedding a reference to the image in the text and then writing the code to parse it. So instead of this: here is some text img src=bird.gif width=100 height=20 alt=this is a bird and here is more text and another image img src=plane.gif width=123 height=23 alt=this is a plane and more text I would like to have something like this: here is some text [bird.gif,this is a bird] and here is more text and another image [plane.gif, this is a plane] and more text Crossing line boundaries is not an issue - each text string is complete. I need to be able to dump out the string until I see a reference to an image, then extract the name and alt text, handle it (by emitting IMG) and continue to echo text from the string until I encounter another image reference. My problem is in coming up with a syntax for this and then to write the code to extract the information. In the above example, I'm using the syntax: [filename,text] but it's conceivable that the HTML text might also contain [some plain text not related to images] so I thought about some of these: {filename,alt text} - not good, text might contain {plain text] @filename, alt text@ img(filename,alt text) Using the same @ delimiter at each end might make it easier to use explode() to split the text. But perhaps img(filename,text) is more elegant, but it might need more skills than I have in using regex to recognize it and extract it. Also I need to figure out how to extract and echo the plain text around it. Any ideas are appreciated. Thanks. -- John A. Grant * I speak only for myself * (remove 'z' to reply) Radiation Geophysics, Geological Survey of Canada, Ottawa If you followup, please do NOT e-mail me a copy: I will read it here -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] accessing localtime array directly
In Perl I have done this: $julianday=(localtime)[7]; Is there an equivalent syntax for PHP or do I just do: $now=localtime(); $julianday=$now[7]; I don't need it - I'm just curious about the syntax. -- John A. Grant * I speak only for myself * (remove 'z' to reply) Radiation Geophysics, Geological Survey of Canada, Ottawa If you followup, please do NOT e-mail me a copy: I will read it here -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: read file twice or read into array once?
Richard Lynch [EMAIL PROTECTED] wrote in message 046901c14d62$b4c7a0c0$c801a8c0@Lynchux100">news:046901c14d62$b4c7a0c0$c801a8c0@Lynchux100... 100 lines of 200 chars each is 2 which is 20K which is chump change for RAM... Unless you are on a super busy page on a super high-volume server, just file() it. If you're on a super busy page on a super high-volume server, file() it anyway, and then ap benchmark it to see if it's slim enough -- And if not, profile it to be sure it's the file() that's killing you, not something else. I realized it was insignificant amount of memory, but I wasn't sure about whether this was ok or not in a server environment. I will use file() and investigate further if it seems slow. Thanks. -- John A. Grant * I speak only for myself * (remove 'z' to reply) Radiation Geophysics, Geological Survey of Canada, Ottawa If you followup, please do NOT e-mail me a copy: I will read it here -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] which regexp require preg_grep() and which can be used with ereg()?
In Perl I used /\S/ to check for blank lines read from a file. Now I'm learning PHP. How do I know what is a 'standard' regexp that ereg() can handle and how do I know what is Perl-specific syntax so that I must use preg_grep() instead? For example, can I use ereg(\S,$buffer) to check for a blank or must I use preg_grep()or that. What specific things require preg_grep() to be used instead of ereg()? Thanks. -- John A. Grant * I speak only for myself * (remove 'z' to reply) Radiation Geophysics, Geological Survey of Canada, Ottawa If you followup, please do NOT e-mail me a copy: I will read it here -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] newbie - some simple questions
Rasmus Lerdorf [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... [...] Thanks for the help tips. I guess I'll use .inc for files that are included (as opposed to being run directly) and block access to them at the server level. Hmm, since the directory always has an index.html, clients will never see the filename anyway and could only run it by guessing at the name, so it's a small point. -- John A. Grant * I speak only for myself * (remove 'z' to reply) Radiation Geophysics, Geological Survey of Canada, Ottawa If you followup, please do NOT e-mail me a copy: I will read it here -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] read file twice or read into array once?
I have a file containing ~100 lines of text, each perhaps 100-200 characters in length. I need to retrieve line $n from the file, where: $n = $julianday % $nlines; $julianday = today's date (from localtime[7]) $nlines = no. of lines in the file Method A 0. fopen() the file 1. read the file line by line with fgets() and count the lines ($nlines) 2. compute the required entry: $n=$julianday % $nline 3. rewind() the file and read it again until entry $n is found 4. fclose() the file Method B 1. read the entire file into memory: $lines=file(myfile) 2. compute the required entry: $n=$julianday % count($lines) I appreciate that this depends on the no. of lines in the file and the size of the file. What I'm looking for is opinions on whether the use of file() is more efficient than fgets(). It needs more memory, but it eliminates reading the file twice. Thanks. -- John A. Grant * I speak only for myself * (remove 'z' to reply) Radiation Geophysics, Geological Survey of Canada, Ottawa If you followup, please do NOT e-mail me a copy: I will read it here -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] newbie - some simple questions
I'm just getting started with php 4.03. Yes I've read the FAQ and lots of documentation. I have setup my pages so they all look more or less like this: ?php require(mylib.php); ? html head ?php myheader(this is the title); ? meta name=keywords content=apples, oranges ... /head ?php mybody(this is the title); ? phere is the body of the page/p ?php myfooter(); ? /html Just for the record, there is a lot of php code in mybody() to emit HTML code for top side nav bars etc. My questions are: 1. every page on the site has: require(mylib.php); at the top of the page to provide access to the functions contained therein. Is require() correct or should I use include()? 2. should mylib.php be called mylib.inc instead? It works fine as mylib.php. If I use include() instead of require() would the filename extension be different, i.e. mylib.inc? 3. I pass the same title to myheader() and to mybody() as shown above. In the first case, it is emitted as title.../title and in the 2nd case is it emitted as h1.../h1. Is there a way to set this up so I only need to have one instance of the title passed to a function? 4. I have some of the HTML xxx tags in the code (i.e. title, body and some in the actual xxx.php page, i.e. html, head (as above). I suppose myheader() could have emitted htmlhead and myfooter() could have emitted /html. I'm trying to develop some sense of style for this, but I'm working in a vacuum. Are there any opinions or guidelines on how to write php code in terms of which tags are visible in the page and which tags are emitted by functions in other modules? 5. I see there is a php.template newsgroup, but I couldn't really follow the conversations. Is that group for discussing ways to implement a design template in php so that all pages have the same appearance? I guess that's what I'm doing with my mylib.php module - the functions dump out the same nav bars to every page. Thanks. -- John A. Grant * I speak only for myself * (remove 'z' to reply) Radiation Geophysics, Geological Survey of Canada, Ottawa If you followup, please do NOT e-mail me a copy: I will read it here -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]