(Crossposted and followups set. Hope you don't mind Markus.)
The Manual expresses the parameters of htmlentities as:
string string [, int quote_style [, string charset]] http://www.php.net/manual/en/function.htmlentities.php
The meaning is unambiguous: the first parameter, "string", must be
present; the second parameter, "quote_styl e", is optional; and the
final parameter, "charset", is optional too, but its presence
requires the, prima facie, ought-to-be dispensable second
parameter.
Why does the existence of the charset parameter depend on the
existence of the quote_style parameter? What's the connection?
--
Jock 6 2288
"John Dunlop" <jo*********@jo hndunlop.info> wrote in message
news:MP******** *************** *@news.freeserv e.net... (Crossposted and followups set. Hope you don't mind Markus.)
The Manual expresses the parameters of htmlentities as:
string string [, int quote_style [, string charset]]
http://www.php.net/manual/en/function.htmlentities.php
The meaning is unambiguous: the first parameter, "string", must be present; the second parameter, "quote_styl e", is optional; and the final parameter, "charset", is optional too, but its presence requires the, prima facie, ought-to-be dispensable second parameter.
Why does the existence of the charset parameter depend on the existence of the quote_style parameter? What's the connection?
You can't pass an optional 3rd parameter if there isn't a second parameter,
otherwise it would be the second parameter. :)
Paulus
"John Dunlop" <jo*********@jo hndunlop.info> schrieb im Newsbeitrag
news:MP******** *************** *@news.freeserv e.net... (Crossposted and followups set. Hope you don't mind Markus.)
No problem; I am not really a usenet specialist...
The Manual expresses the parameters of htmlentities as:
string string [, int quote_style [, string charset]]
http://www.php.net/manual/en/function.htmlentities.php
That's interesting; I had not seen this before.
The meaning is unambiguous: the first parameter, "string", must be present; the second parameter, "quote_styl e", is optional; and the final parameter, "charset", is optional too, but its presence requires the, prima facie, ought-to-be dispensable second parameter.
Why does the existence of the charset parameter depend on the existence of the quote_style parameter? What's the connection?
The quote_style parameter only defines which quotes to replace (only double
quotes, both single and double, or none of them), there is no way to define
what they are going to be replaced by. Double quotes are replaced by "
and single ones by '
I tried this with Latin-1 and Chinese Big 5 encodings, there was no
difference.
So I think it is just the name of the parameter "quote_styl e" which is
confusing, as you don't set the style. You can't set them to ’ or
» or ASCII something, or whatever. So it seems to be independent from
the encoding but rather just provide a possibility for coders to handle
quotes in connection with their coding style, as in some cases you might
want to keep a " as it is and not replace it by "
--
Markus
Markus Ernst wrote: So I think it is just the name of the parameter "quote_styl e" which is confusing, as you don't set the style.
I hadn't actually considered that. But, with further pondering, I
believe the parameter's name could've conceivably been better
chosen. Dare I say a misnomer even?
So [quote_style] seems to be independent from the encoding [...]
Yes, that's the crux of the matter. The conversion of quotation
marks *is* independent of the character set.
Why must I explicitly set the quote_style value -- even if that
value is equivalent to its default -- whenever I wish to use a
different character set? Why is quote_style not optional whenever
I change character sets?
IOW, why is the parameters' notation not:
string string [, int quote_style] [, string charset]
--
Jock
On Thu, 9 Oct 2003 11:28:01 +0100, John Dunlop wrote: IOW, why is the parameters' notation not:
string string [, int quote_style] [, string charset]
Not possible in PHP. That would require something like a strongly
typed language (e.g. Java or C++) and overloading. This is not really
what PHP is.
Gerhard Fiedler wrote: string string [, int quote_style] [, string charset]
Not possible in PHP. That would require something like a strongly typed language (e.g. Java or C++) and overloading. This is not really what PHP is.
Right. A slip-up on my part then. Thank you.
After further reading, I notice that The Manual's notes about "How
to read a function definition (prototype)" says next to nothing
about optional parameters. Someone without much knowledge, reading
that page -- me to a tee! -- might benefit from supplementary
documentation. http://www.php.net/manual/en/about.prototypes.php
So, RTFM was unsuccessful. And so was googling, which brought up
page upon page of clues about optional parameters and variable-
length parameter lists in *user-defined* functions. The Manual
already explains those in enough detail IMO. Ho hum. http://www.php.net/manual/en/functions.arguments.php
Thanks again, Gerhard.
--
Jock
On Thu, 9 Oct 2003 17:35:24 +0100, John Dunlop wrote: >string string [, int quote_style] [, string charset]
Not possible in PHP. That would require something like a strongly typed language (e.g. Java or C++) and overloading. This is not really what PHP is.
Right. A slip-up on my part then. Thank you.
No problem.
I actually didn't include everything above. What I sometimes do with
user-defined functions in such cases (but that's not what the PHP
internal functions do) is to pass in an associative array. This has
the same effect as named arguments, and then the order is not relevant
anymore, and whan needs to be supplied is no longer restricted by the
language syntax, but only by the program logic. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Randell D. |
last post by:
Folks,
I'm using Apache/1.3.28 (SuSE 7.1, kernal 2.4) with PHP/4.3.2. I have the
following code to help cleanse form data.
function cleanData($sourceData, &$cleanData)
{ foreach($myData as $fieldName=>$fieldValue)
{ if(strlen($fieldValue)>0)
{ $cleanData=htmlentities(trim($fieldValue)); }
else
{ $cleanData=""; }
|
by: knocker |
last post by:
Hi
I have a problem with JSP on websphere 5. When I try save information
with swedish or danish ÅÄÖ characters, the string is cut where the
first of these characters occurs. The JDK used is 1.3.1
I've tried:
String CUNM = request.getParameter("CUNM").trim();
CUNM = URLDecoder.decode(CUNM,"UTF-8");
|
by: Alcyone Oliveira |
last post by:
------=_NextPart_000_000D_01C36572.F6480CE0
Content-Type: multipart/alternative;
boundary="----=_NextPart_001_000E_01C36572.F6480CE0"
------=_NextPart_001_000E_01C36572.F6480CE0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
|
by: mimmo |
last post by:
Hi! I should convert the accented letters of a string in the correspondent
letters not accented. But when I compile with -Wall it give me:
warning: multi-character character constant
Do the problem is the charset? How I can avoid this warning? But the worst
thing isn't the warning, but that the program doesn't work! The program
execute all other operations well, but it don't print the converted
letters: for example, in the string...
|
by: musosdev |
last post by:
Hi guys
I've got the following error on a project which is running locally on a
vs2005 machine (built in webserver), trying to connect to my win2k3 server
active directory.
the error is...
System.SystemException: The trust relationship between this workstation and
the primary domain failed.
| |
by: Taras_96 |
last post by:
Hi all,
I was hoping to get some clarification on a couple of questions I have:
1) When should htmlspecial characters be used? As a general rule should
it be used for text that may contain special characters that is going
to be rendered in the browser (ie: text that isn't in tags)? I've got a
javascript onclick handler whose code includes an ampersand and the
HTML validator complains. I don't know if I should escape the
ampersand, or...
|
by: jacob navia |
last post by:
Recently, a heated debate started because of poor mr heathfield
was unable to compile a program with // comments.
Here is a utility for him, so that he can (at last) compile my
programs :-)
More seriously, this code takes 560 bytes. Amazing isn't it? C is very
ompact, you can do great things in a few bytes.
Obviously I have avoided here, in consideration for his pedantic
|
by: mijn naam |
last post by:
Can someone please explain to me why/when one would use htmlspecialchars
instead of htmlentities?
I know: if you only want to get certain characters translated. This is not
the answer I'm looking for, I would like to know *why* you would want that,
as opposed to a full translation.
|
by: mukeshrasm |
last post by:
Hi I am no able to send mail and it is giving this error
Warning: mail(): SMTP server response: 530 5.7.3 Client was not authenticated in c:\inetpub\wwwroot\eshop\includes\classes\email.php on line 522
and the code is:
<?php
/*
$Id: email.php,v 1.12 2003/06/17 17:29:44 dgw_ Exp $
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |