Newbie question

From: Date: Fri, 02 May 2003 00:36:03 +0000
Subject: Newbie question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-146034@lists.php.net to get a copy of this message
I am a newbie to php, but have been using Zope, DTML and Python for the last year or so. I have figured out a couple of things that are similar between DTML and PHP so far, such as testing for browser versions. DTML - <dtml-if "_.string.find(HTTP_USER_AGENT, 'MSIE') >= 0"> MSIE code <dtml-elif "_.string.find(HTTP_USER_AGENT, 'Mozilla/5') >= 0"> Mozilla/5 code <dtml-elif "_.string.find(HTTP_USER_AGENT, 'Mozilla/4') >= 0"> Mozilla/4 code <dtml-else> Generic code </dtml-if> PHP - <?php if (stristr($_SERVER['HTTP_USER_AGENT'],'MSIE')) : ?> MSIE code <?php elseif (stristr($_SERVER['HTTP_USER_AGENT'],'Mozilla/5')) : ?> Mozilla/5 code <?php elseif (stristr($_SERVER['HTTP_USER_AGENT'],'Mozilla/4')) : ?> Mozilla/4 code <?php else: ?> Generic code <?php endif; ?> One question I have is, how do you test for a property or a cookie? In DTML it would be: <dtml-call "REQUEST.has_key('property or cookie')"> Enter block of code <dtml-else> Enter another block of code </dtml-if> Is ther a way to do this in PHP without having to echo each line? I've tried <?php if (isset[property or cookie]) ; ?> Enter Block of Code <?php endif; ?> But that errors out. Another question I have is can a cookie be set within the HTML and how would I do it? In DTML you can set them anywhere within the document you want: <dtml-call "RESPONSE.setCookie(cookieName, 'value', path='/')"> I have figured out how to set cookies in PHP but only before the html starts, otherwise I get an error. <?php setcookie('testCookie', 'value','path'); ?> Any help, suggestions or pointers would be appreciated. Michael -- Michael Lewis NicheStaffing.com <michael@nichestaffing.com>

« previous php.general (#146034) next »