RE: [PHP] Remote Key Question

2010-04-23 Thread David Murphy
Personally I would make

-Original Message-
From: Adam Richardson [mailto:simples...@gmail.com] 
Sent: Friday, April 23, 2010 11:09 AM
To: tedd
Cc: PHP eMail List
Subject: Re: [PHP] Remote Key Question

On Fri, Apr 23, 2010 at 12:03 PM, tedd t...@sperling.com wrote:

 Hi gang:

 A few times I've found myself confronted with a problem that might be
 better solved than the way I currently solve it. I would like your
 opinions/solutions as to how you might solve this.

 Here's the given (as an article/author example).

 I want to create a list of articles in a database.

 The articles are listed in a table with the fields title, description,
 and author.

 article table:
 id - title - description - author

 The authors are listed in a table with the fields name and bio.

 author table:
 id - name - bio

 Now here's the problem each articles will have one, but perhaps more
 authors -- so how do I record the authors in the article table?

 As it is now, I use the remote key for each author and separate each key
by
 a comma in the author field of the article table. For example:

 author table:
 id - name - bio
 1 - tedd - tedd's bio
 2 - Rob - Rob's bio
 3 - Daniel - Daniel's bio

 article table:
 id - title - description - author
 1 - PHP Beginner - Beginner Topics - 1
 2 - PHP Intermediate - Intermediate Topics - 1,2
 3 - PHP Advanced - Advanced Topics - 1,2,3

 As such, article with id=3 has a title of  PHP Advanced and a
description
 of Advanced Topics with tedd, Rob, and Daniel as authors.

 Is there a better way to link multiple authors to an article rather than
 placing the remote keys in one field and separating them with commas?

 Cheers,

 tedd

 --
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


Well, because each author can have multiple articles and each article can
have multiple authors, the many-to-many relationship can use a junction
table:

http://en.wikipedia.org/wiki/Junction_table

In this case articles_authors.

Adam

-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Remote Key Question

2010-04-23 Thread David Murphy
GRR I hate outlook veruses Trillian




Personally I would make



Author:
Id|Name|Bio

Article:
Id,title,desc,authordata


So then I can do things like

Select Articles.Title, article.Description,(select GROUP_CONCAT(Name) from
authors where authors.ID IN Articles.AuthorData) as Authors from Articles
where Articles.ID=XXX


Then php could $tAuthors=explode(,,$row['Authors']); and pass that into
smarty or whatever for the view portion of the  app.

I just say this because Junction tables really don't save you much  and
infact this it's very clear what your doing.

David

-Original Message-
From: Adam Richardson [mailto:simples...@gmail.com] 
Sent: Friday, April 23, 2010 11:09 AM
To: tedd
Cc: PHP eMail List
Subject: Re: [PHP] Remote Key Question

On Fri, Apr 23, 2010 at 12:03 PM, tedd t...@sperling.com wrote:

 Hi gang:

 A few times I've found myself confronted with a problem that might be
 better solved than the way I currently solve it. I would like your
 opinions/solutions as to how you might solve this.

 Here's the given (as an article/author example).

 I want to create a list of articles in a database.

 The articles are listed in a table with the fields title, description,
 and author.

 article table:
 id - title - description - author

 The authors are listed in a table with the fields name and bio.

 author table:
 id - name - bio

 Now here's the problem each articles will have one, but perhaps more
 authors -- so how do I record the authors in the article table?

 As it is now, I use the remote key for each author and separate each key
by
 a comma in the author field of the article table. For example:

 author table:
 id - name - bio
 1 - tedd - tedd's bio
 2 - Rob - Rob's bio
 3 - Daniel - Daniel's bio

 article table:
 id - title - description - author
 1 - PHP Beginner - Beginner Topics - 1
 2 - PHP Intermediate - Intermediate Topics - 1,2
 3 - PHP Advanced - Advanced Topics - 1,2,3

 As such, article with id=3 has a title of  PHP Advanced and a
description
 of Advanced Topics with tedd, Rob, and Daniel as authors.

 Is there a better way to link multiple authors to an article rather than
 placing the remote keys in one field and separating them with commas?

 Cheers,

 tedd

 --
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


Well, because each author can have multiple articles and each article can
have multiple authors, the many-to-many relationship can use a junction
table:

http://en.wikipedia.org/wiki/Junction_table

In this case articles_authors.

Adam

-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Remote Key Question

2010-04-23 Thread David Murphy
-Original Message-
From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: Friday, April 23, 2010 11:16 AM
To: tedd
Cc: PHP eMail List
Subject: Re: [PHP] Remote Key Question

On Fri, 2010-04-23 at 12:03 -0400, tedd wrote:
 Hi gang:
 
 A few times I've found myself confronted with a problem that might be 
 better solved than the way I currently solve it. I would like your 
 opinions/solutions as to how you might solve this.
 
 Here's the given (as an article/author example).
 
 I want to create a list of articles in a database.
 
 The articles are listed in a table with the fields title, 
 description, and author.
 
 article table:
 id - title - description - author
 
 The authors are listed in a table with the fields name and bio.
 
 author table:
 id - name - bio
 
 Now here's the problem each articles will have one, but perhaps more 
 authors -- so how do I record the authors in the article table?
 
 As it is now, I use the remote key for each author and separate each 
 key by a comma in the author field of the article table. For example:
 
 author table:
 id - name - bio
 1 - tedd - tedd's bio
 2 - Rob - Rob's bio
 3 - Daniel - Daniel's bio
 
 article table:
 id - title - description - author
 1 - PHP Beginner - Beginner Topics - 1
 2 - PHP Intermediate - Intermediate Topics - 1,2
 3 - PHP Advanced - Advanced Topics - 1,2,3
 
 As such, article with id=3 has a title of  PHP Advanced and a 
 description of Advanced Topics with tedd, Rob, and Daniel as 
 authors.
 
 Is there a better way to link multiple authors to an article rather 
 than placing the remote keys in one field and separating them with 
 commas?
 
 Cheers,
 
 tedd
 
 -- 
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com
 

If you can change the authors table couldn't you add a article_id field
to it? If not, or if an author may belong to more than one article (many
to many) then a third table is the way to go, and use a couple of joins.

A third table does have the added advantage that you might specify the
type of author they were. For example:

idauthor_idarticle_idtype(enum maybe?)
1 11 main
2 21 co
3 12 main

The third table is obviously more complex, but offers a better
relationship model to be built between authors and articles.

Thanks,
Ash
http://www.ashleysheridan.co.uk




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Agreed,

It really depended if this is a permission based system or more info based. 
If  its just for listing authors of an article, not letting them edit it,
the  my solution is best but if it was was editing I would go with Ash's
approach maybe even  making is  so its something like



ArticleParts:
ID|ORDER|ArticleID|UserID|ENUM(OWNER,CONTRIBUTOR)


So that the owner can edit any ArticlePart in their article but the
CONTRIBUTOR can only edit their specific part. And ordery would tell you how
to order the parts for final output.


David


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] RE: mysql query returning slowly

2010-04-07 Thread David Murphy
Nathan,


The profiling I included proved that was not the case.

Mysql run the query and return the single column single  row result in under
1 second but  PHP's mysql-query waited much longer than that to return.  If
it was a big result set I could  see some slow down in parsing the results
into memory but  this wasn't the case. Updates/Deletes have similar random
timing  issues , and using mysql profiling, I can see its not transit or
lock or  clean up time from mysql - php , it is purely inside the php
mysql functions  the slow down seems to be occurs , but I can dive into
those as they are compiled modules not  userland functions.

-Original Message-

-Original Message-
From: Nathan Rixham [mailto:nrix...@gmail.com] 
Sent: Tuesday, April 06, 2010 6:35 PM
To: David Murphy
Cc: php-general@lists.php.net
Subject: Re: mysql query returning slowly

David Murphy wrote:
  
 This is from our application 
 I enabled profile in mysql to determine why an update took 20seconds.  As
 you can see  MySQL reported no where near that amount of duration took
 place. 
 Is there any way I can dig into php and determine why  mysql client libs
are
 so slow (this is not using mysqlnd but  mysql-client-libs on CentOS using
 5.3.2)
  
  
 04/06/2010 14:54:54 20.6899s

maybe it was waiting to acquire a lock


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] mysql query returning slowly

2010-04-06 Thread David Murphy
 
This is from our application 
I enabled profile in mysql to determine why an update took 20seconds.  As
you can see  MySQL reported no where near that amount of duration took
place. 
Is there any way I can dig into php and determine why  mysql client libs are
so slow (this is not using mysqlnd but  mysql-client-libs on CentOS using
5.3.2)
 
 
04/06/2010 14:54:54 20.6899s  UPDATE `calls` SET `Result`='Busy' WHERE
`CallID`='144786'
 | Status   | Duration | CPU_user | CPU_system |
Context_voluntary | Context_involuntary | Block_ops_in | Block_ops_out |
Messages_sent | Messages_received | Page_faults_major | Page_faults_minor |
Swaps | 
 


--
 | starting | 0.39 | 0.00 | 0.00   | 0
| 0   | 0| 0 | 0 | 0
| 0 | 0 | 0 | 
 | checking permissions | 0.08 | 0.00 | 0.00   | 0
| 0   | 0| 0 | 0 | 0
| 0 | 0 | 0 | 
 | Opening tables   | 0.10 | 0.00 | 0.00   | 0
| 0   | 0| 0 | 0 | 0
| 0 | 0 | 0 | 
 | System lock  | 0.05 | 0.00 | 0.00   | 0
| 0   | 0| 0 | 0 | 0
| 0 | 0 | 0 | 
 | Table lock   | 0.06 | 0.00 | 0.00   | 0
| 0   | 0| 0 | 0 | 0
| 0 | 0 | 0 | 
 | init | 0.36 | 0.00 | 0.00   | 0
| 0   | 0| 0 | 0 | 0
| 0 | 0 | 0 | 
 | Updating | 0.99 | 0.001000 | 0.00   | 0
| 0   | 0| 0 | 0 | 0
| 0 | 0 | 0 | 
 | end  | 0.23 | 0.00 | 0.00   | 0
| 0   | 0| 0 | 0 | 0
| 0 | 0 | 0 | 
 | query end| 0.04 | 0.00 | 0.00   | 0
| 0   | 0| 0 | 0 | 0
| 0 | 0 | 0 | 
 | freeing items| 0.007410 | 0.00 | 0.00   | 4
| 1   | 0| 0 | 0 | 0
| 0 | 0 | 0 | 
 | logging slow query   | 0.04 | 0.00 | 0.00   | 0
| 0   | 0| 0 | 0 | 0
| 0 | 0 | 0 | 
 | cleaning up  | 0.04 | 0.00 | 0.00   | 0
| 0   | 0| 0 | 0 | 0
| 0 | 0 | 0 |

 

 

Thanks

David Murphy



RE: [PHP] Drawing Images Without Writing To a File

2010-03-11 Thread David Murphy
Also you should think about  writing those files  a memcache or something.

That way   the image can expire but you're not wasting a lot of cpu cycles,
aka   500 hits to the site at the same time would be  very  intensive, but
if someone hit the site 10 minutes ago with a  700 ttl,  the would load the
image instantly from ram ;)

Also a method I like is 


class thumbnail  {

 function __construct($baseFileName){
 if (!file_exists(THUMBS./.$baseFileName)
 $this-generateThumbnail($baseFileName);
 return $this-outputThumbContents($baseFileName);
 }
 function outputThumbContents($sFileName){
 //Reads file and echo its  header/contents
 }
}

Which of course you could make  check a  memcache location instead or
memcache,file,then build if neither is present. :)

David 

-Original Message-
From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: Thursday, March 11, 2010 9:26 AM
To: Floyd Resler
Cc: PHP
Subject: Re: [PHP] Drawing Images Without Writing To a File

On Thu, 2010-03-11 at 10:27 -0500, Floyd Resler wrote:

 I want to draw tabs in a tab bar without having to actually write the
images to a file.  Is it possible to generate the image and send the data
back and make the browser think it's loading an image file?  I know this can
be done by sending the proper headers back for an entire page, but I just
want to do basically the same thing for just part of the page.
 
 Thanks!
 Floyd
 
 


Have the image tag call a script which generates the images based on
parameters in the filename:

img src=image.php?param1=somethingparam2=something_else/

Then you can have PHP read in the GET data and generate any image you
need.

Thanks,
Ash
http://www.ashleysheridan.co.uk




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] outlook calendar entry on the fly

2010-03-11 Thread David Murphy
http://www.phpclasses.org/browse/package/873.html

Should do the trick for you.

-Original Message-
From: Jack [mailto:jacklistm...@gmail.com] 
Sent: Thursday, March 11, 2010 12:24 PM
To: php-general@lists.php.net
Subject: [PHP] outlook calendar entry on the fly

Does anyone have any reference to some php code which would allow me to have
a person go to a website, pick an appointment time and date and then create
a clickable link which could populate outlook with the appointment.  I
believe this is an .ics file which outlook needs/reads.

 

 

Thanks!

Jack

 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] App to put a whole PHP Site in CD/DVD

2010-03-02 Thread David Murphy
ThinAPP by VMware is  a better alternative I think, it makes the VM into an
EXE, so autorun will load the exe, which you can set a windows or full
screen. Of course this isn't  free.


Also RoadsendPHP  http://roadsend.com  can package an app in offline mode,
with an embedded web server (MicroServer).  

Depending on your needs not sure which is most applicable for you.
But its atleast free :) and you could compile for linux and windows and let
autorun launch the windows one and users launch the linux one.


David 

-Original Message-
From: Daevid Vincent [mailto:dae...@daevid.com] 
Sent: Tuesday, March 02, 2010 2:24 PM
To: 'Juan'; php-general@lists.php.net
Subject: RE: [PHP] App to put a whole PHP Site in CD/DVD

What we've done is use VMWare Workstation (free fully working trial
available) to build a LAMP VM. 

VMWare Player is a free download to anyone, so we just send the VM (.vmdk
files, etc.) and they run it.

The same could be done with VirtualBox or the Virtualization tool of your
choice. 

 -Original Message-
 From: Juan [mailto:j...@rodriguezmonti.com.ar] 
 Sent: Tuesday, March 02, 2010 3:12 AM
 To: php-general@lists.php.net
 Subject: [PHP] App to put a whole PHP Site in CD/DVD
 
 Hi,
 I need an application to run mysql/php/apache or similar in one cd, to
 make a presentation.
 
 The presentation itself is a php site that uses mysql to do some
 queries, to show data, and I would like to know how to embbed php and
 mysql to one cd for a presentation. I mean; one cd containing the
 whole site, and when the user inserts it on the cd/dvd reader it's
 able to use the website like if him/her would be using the http
 protocol. So, this application should let me put mysql/php/apache in
 the cd, then it should work from the cd.
 
 I would like to use some free software application, I would like to
 avoid using commercial branches because I need this for a commercial
 project that isn't able to pay licenses. Also I preffer Free Software.
 
 So, if you know some appplication that helps me to develop this, and
 also if I would be able to make the cd multiplatform for the principal
 OS ( Gnu/linux, win, mac ) even better.
 
 Thanks a lot.
 
 Juan
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] $_POST vs $_REQUEST

2010-02-22 Thread David Murphy
Richard,


The use of $_REQUEST it no more a security hole than $_GET or $_REQUEST,
they should ALL be treats as bad data until normalized and sanitized.  The
claim that it opens a security hole  is  just false, that’s like saying PHP
is insecure, its not it just allows for lazy coding such as $_REQUEST. 


David Murphy

-Original Message-
From: richard.he...@gmail.com [mailto:richard.he...@gmail.com] On Behalf Of
Richard
Sent: Monday, February 22, 2010 3:03 PM
To: Joseph Thayne
Cc: Slack-Moehrle; php-general
Subject: Re: [PHP] $_POST vs $_REQUEST

Hi,

 I am not sure what the security issues are you are referring to as the
 $_REQUEST superglobal contains both $_GET and $_POST values.  Could you
 expound on that?  Thanks.

Not really, do a search.

-- 
Richard Heyes
HTML5 canvas graphing: RGraph - http://www.rgraph.net (updated 20th
February)
Lots of PHP and Javascript code - http://www.phpguru.org

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Thinking of moving to .NET because of standalone... any suggestions?

2010-02-03 Thread David Murphy
Ryan, 

You may want to consider:

NuSphere PhpDock - unique PHP deployment solution

PhpDock is a deployment platform for PHP applications.
PhpDock enables you to deploy PHP web application as a Stand Alone Windows
Desktop application w/o any changes in the code.
PhpDock combines NuSphere's powerful embeded Srv webserver and the browser
components.

With PhpDock, your php applications will work right out of the box. There's
no need to provide long and complicated instructions on Apache and Php
installation to your clients. PhpDock site license lets you distribute this
deployment solution along with your php applications to provide easy and
comprehensive installation and instant functioning of your php scripts.


http://www.nusphere.com/products/phpdock.htm

Hope this helps
David Murphy


-Original Message-
From: Ryan S [mailto:gen...@yahoo.com] 
Sent: Wednesday, February 03, 2010 11:10 AM
To: php php
Subject: [PHP] Thinking of moving to .NET because of standalone... any
suggestions?

Hey Guys,

Coming from a C and Java background I just loved PHP and have been
programming with it for years thanks in a large part to the kind people on
this list... present and past (Immediately the name John Holmes comes to
mind.. i hope the dude is well)
but now I have have to leave PHP or split time between php and .NET for just
one reason:

.NET offers a way to run programs using the Windows GUI / stand alone
executable

There always was talk on the list about running php code as standalone, but
since I had a long absence from the list sorry if I missed any new
updates... but I'm hoping someone can offer a way to run php standalone
executable.

Before posting I always google, and the main results I have gotten so far
is:
priado blender
and PHP-GTK

but no way to kind of drag and drop what you need like visual studio (i dont
know how to use it yet, but been reading) or some other visual development
tool like visual basic.

I need to make a few standalones programs that will run (mostly) on
Windows... is there any other way that I have not found that i can use PHP
instead of learning something new like .NET?

I have resisted going the microsoft way for years.. looks like my luck has
run out...

Thanks,
Ryan



  

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] What is the best practice for adding persistence to an MVC model?

2009-10-27 Thread David Murphy
I take a  different  approach :


// In the  MainHandler

Define('StorageClassName',_MySQL);

Class UserController {
function __construct($objDataStore=false){
if(!$objDataStore)
$this-DataStore = new 
instanceof($this).STORAGECLASSNAME ;
}
Function update(){
$data = $this-DataStore-Load(foo);
$data-Set(foo,bar);
$data-save;
}


This assumes your using DBO  so the loaded foo object inherited the 
settings/methods from the DB Datastore.
Thus letting you  passing a different datastore object  or  it builds one based 
on the model name and the storage type you set as a constant.

However it still links the two together so you can use  $this calls to 
reference the DataStore of the Model layer.

David
 -Original Message-
 From: Mert Oztekin [mailto:mozte...@anadolusigorta.com.tr]
 Sent: Tuesday, October 27, 2009 6:14 AM
 To: 'Eric Bauman'; php-general@lists.php.net
 Subject: RE: [PHP] What is the best practice for adding persistence to an MVC
 model?
 
 Hi Eric,
 
 IMO, controllers shouldnt be responsible for interacting models and
 datastoreres. Controllers might only change the datastore class of a model.
 
 You may use your models in lots of controller functions. Defining datastore in
 all controllers seems not a good practice. (too much unneccessary codes
 written)
 
 A simple example
 
 //controller
 Public function doItController()
 {
 $user = new user();
 // $user-setDataStorer(new anotherDataStorer());   // this is 
 optional if
 you want to change models datastorer
 $user-loadUserFromId(1);
 }
 
 // model
 Class user
 {
 Protected $_dataStorer = null;
 
 Public function loadUserFromId($id = 0)
 {
 // codes codes codes
 $result =   $this-getDataStorer()-query(select .);
 // codes codes codes
 }
 
 // codes codes codes
 Public function getDataStorer()
 {
 if(null == $this-_dataStorer)
 $this-_dataStorer = new myVeryBestDataStorer();
 return $this-_dataStorer;
 }
 
 Public function setDataStorer($newStorer)
 {
 $this-_dataStorer = $newStorer;
 }
 }
 
 
 Hope it will be usefull and understandable
 
 -Original Message-
 From: Eric Bauman [mailto:baum...@livejournal.dk]
 Sent: Tuesday, October 27, 2009 8:27 AM
 To: php-general@lists.php.net
 Subject: [PHP] What is the best practice for adding persistence to an MVC
 model?
 
 I'm in the process of implementing an ultra-light MVC framework in PHP.
 It seems to be a common opinion that the loading of data from a database,
 file etc. should be independent of the Model, and I agree.
 What I'm unsure of is the best way to link this data layer into MVC.
 
 I've considered a few options:
 
 *Datastore interacts with Model*
 
 //controller
 public function update()
 {
 
   $model = $this-loadModel('foo');
   $data = $this-loadDataStore('foo', $model);
 
   $data-loadBar(9); //loads data and populates Model
   $model-setBar('bar');
   $data-save(); //reads data from Model and saves
 
 }
 
 *Controller mediates between Model and Datastore*
 
 Seems a bit verbose and requires the model to know that a datastore exists.
 
 //controller
 public function update()
 {
 
   $model = $this-loadModel('foo');
   $data = $this-loadDataStore('foo');
 
   $model-setDataStore($data);
 
   $model-getDataStore-loadBar(9); //loads data and populates Model
   $model-setBar('bar');
   $model-getDataStore-save(); //reads data from Model and saves
 
 }
 
 *Datastore extends Model*
 
 What happens if we want to save a Model extending a database datastore to
 a flatfile datastore?
 
 //controller
 public function update()
 {
 
   $model = $this-loadHybrid('foo'); //get_class == Datastore_Database
 
   $model-loadBar(9); //loads data and populates
   $model-setBar('bar');
   $model-save(); //saves
 
 }
 
 *Model extends datastore*
 
 This allows for Model portability, but it seems wrong to extend like this.
 Further, the datastore cannot make use of any of the Model's methods.
 
 //controller extends model
 public function update()
 {
 
   $model = $this-loadHybrid('foo');  //get_class == Model
 
   $model-loadBar(9); //loads data and populates
   $model-setBar('bar');
   $model-save(); //saves
 
 }
 
 
 
 Any input on the best option - or alternative - would be most appreciated.
 
 --
 PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
 http://www.php.net/unsub.php
 
 
 Bu mesaj ve ekleri, mesajda gönderildiği belirtilen kişi/kişilere özeldir ve
 gizlidir. Size yanlışlıkla ulaşmışsa lütfen gönderen kisiyi bilgilendiriniz 
 ve mesajı
 sisteminizden siliniz. Mesaj ve eklerinin içeriği ile ilgili olarak 
 şirketimizin
 herhangi bir hukuki sorumluluğu bulunmamaktadır. Şirketimiz mesajın ve
 bilgilerinin 

RE: [PHP] how call a variable in a text

2009-10-21 Thread David Murphy
This is actually much better  the {  and } make it very obvious where the  
variable is and also it can keep odd issues from occurring sometimes.

$message=b There is a text {$variable}  trial. /b ;

There is always sprint type functions also.


David

-Original Message-
From: Andrew Ballard [mailto:aball...@gmail.com] 
Sent: Wednesday, October 21, 2009 3:23 PM
To: Bulend Kolay
Cc: php-general@lists.php.net
Subject: Re: [PHP] how call a variable in a text

2009/10/21 Bulend Kolay bma...@ihlas.net.tr:
 I 'll send a mail in html form using php5.

 cat send.php
 ?php
 $variable=date1 ;
 ..
 ..
 $message='

 b There is a text $variable  trial. /b ';

 mail($to, $subject, $message, $headers) ; ?

 when I run send.php, I get the mail. But I can't call variable called 
 variable. it comes as string.
 How can I correct this?


You need to use double quotes (or HEREDOC) if you want PHP to replace $variable 
with its value in the string:

$message=

b There is a text $variable  trial. /b ;

or

$message = MESSAGE

b There is a text $variable  trial. /b MESSAGE;



Andrew

--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: 
http://www.php.net/unsub.php

No virus found in this outgoing message.
Checked by AVG - www.avg.com
Version: 8.5.423 / Virus Database: 270.14.24/2449 - Release Date: 10/20/09 
18:42:00
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: [PHP] how call a variable in a text

2009-10-21 Thread David Murphy
True however   K.I.S.S  would say , if  you can use it  like

 

 

echo “This is a statement {$Blah}.”;

echo “This is also a statement {$objBlah-BlahString}.”;

echo “This is also a statement {$tBlah[‘BlahKey’]}.”;

 

 

You should do it so you are always using the same expected format, cleaner for 
readability and training other people to understand how you code.

 

 

This is my personal thoughts on it, everyone has their own prefs.

 

David

 

From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: Wednesday, October 21, 2009 3:43 PM
To: David Murphy
Cc: php-general@lists.php.net
Subject: RE: [PHP] how call a variable in a text

 

On Wed, 2009-10-21 at 15:40 -0500, David Murphy wrote: 

 
This is actually much better  the {  and } make it very obvious where the  
variable is and also it can keep odd issues from occurring sometimes.

$message=b There is a text {$variable}  trial. /b ;
 
There is always sprint type functions also.
 
 
David
 
-Original Message-
From: Andrew Ballard [mailto:aball...@gmail.com] 
Sent: Wednesday, October 21, 2009 3:23 PM
To: Bulend Kolay
Cc: php-general@lists.php.net
Subject: Re: [PHP] how call a variable in a text
 
2009/10/21 Bulend Kolay bma...@ihlas.net.tr:
 I 'll send a mail in html form using php5.
 
 cat send.php
 ?php
 $variable=date1 ;
 ..
 ..
 $message='
 
 b There is a text $variable  trial. /b ';
 
 mail($to, $subject, $message, $headers) ; ?
 
 when I run send.php, I get the mail. But I can't call variable called 
 variable. it comes as string.
 How can I correct this?
 
 
You need to use double quotes (or HEREDOC) if you want PHP to replace $variable 
with its value in the string:
 
$message=
 
b There is a text $variable  trial. /b ;
 
or
 
$message = MESSAGE
 
b There is a text $variable  trial. /b MESSAGE;
 
 
 
Andrew
 
--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: 
http://www.php.net/unsub.php
No virus found in this outgoing message.
Checked by AVG - www.avg.com 
Version: 8.5.423 / Virus Database: 270.14.24/2449 - Release Date: 10/20/09 
18:42:00
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


The {} only become really useful when you're trying to reference arrays within 
a string:

$var = array('great', 'boring');

$text = this is {$var[0]}.;

Without the curly braces, PHP wouldn't be able to figure out whether you wanted 
the end string to be 'This is great.' or 'This is [0].' despite the variable 
itself clearly being an array.


Thanks,
Ash
http://www.ashleysheridan.co.uk



 


No virus found in this outgoing message.
Checked by AVG - www.avg.com
Version: 8.5.423 / Virus Database: 270.14.24/2449 - Release Date: 10/20/09 
18:42:00
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: [PHP] Built-in Debugging

2009-10-16 Thread David Murphy
I have to disagree, while   Exception handling and  the like have their
place. Sometimes when you develop you want to stop execution and  look at
your memory stack to make sure you didn't over look something.

Especially if you are relying on someone  else code  and it's not a project
owned 100% by you.


Just my thoughts, they have their place I use  PhpEd, because it facilitates
this nicely and it VERY customizable from a short hand perspective.

-Original Message-
From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: Friday, October 16, 2009 8:05 AM
To: Al
Cc: php-general@lists.php.net
Subject: Re: [PHP] Built-in Debugging

On Fri, 2009-10-16 at 09:04 -0400, Al wrote:

 
 Bob McConnell wrote:
  From: Raymond Irving
  
  Will be ever see built-in debugging features for PHP?
  
  I do not expect there would be. Debuggers are more likely to be 
  provided by the IDE. For example, in MS-Windows, Visual Studio is 
  the IDE and can include any of several compilers. It also includes 
  the debugger, and uses the same front end for all languages. Of 
  course, Microsoft has it much easier since they only support one 
  hardware platform (x86) and one OS. Unlike the rest of the world 
  where tools are more likely to be portable.
  
  For an IDE with debug capabilities, try NetBeans. I am sure there 
  are others, but that is the only one I have actually looked at.
  
  Bob McConnell
 
 phpEdit, a super IDE, has an extensive suite of integrated debug tools.
 


Real coders don't use debugging tools, comments and output statements are
all you need ;)

Thanks,
Ash
http://www.ashleysheridan.co.uk



No virus found in this outgoing message.
Checked by AVG - www.avg.com
Version: 8.5.421 / Virus Database: 270.14.20/2440 - Release Date: 10/16/09 
06:32:00
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php