/    Sign up×
Community /Pin to ProfileBookmark

% symbol problem

Hi all,

I am having a problem including % symbols in php strings.

Escaping them with doesn’t seem to work.

Any ideas?

Cheers,
Rob.

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@GarySMay 22.2006 — Don't think they need to be escaped, do they? What are you using them for?
Copy linkTweet thisAlerts:
@nightsterauthorMay 22.2006 — Yeah, they are giving me problems. I'm using them as part of a table instruction within a printf statement. Here's the statement:

printf("<table width="100%"");

But it is throwing a 'too few arguements' error.

Any ideas?

Thanks!

Rob.
Copy linkTweet thisAlerts:
@felgallMay 22.2006 — % has a special meaning to printf() why not use print() instead?
Copy linkTweet thisAlerts:
@bokehMay 22.2006 — Why are you using [I]printf()[/I] for that. No benefit whatsoever in that instance. Use [I]echo()[/I] or [I]print()[/I] instead.
Copy linkTweet thisAlerts:
@nightsterauthorMay 22.2006 — Why are you using [I]printf()[/I] for that. No benefit whatsoever in that instance. Use [I]echo()[/I] or [I]print()[/I] instead.[/QUOTE]

Ah right, thanks!

To be honest, I always use printf(), habit I guess - I'm not sure why.

Out of interest, what's the difference between them?
Copy linkTweet thisAlerts:
@bokehMay 22.2006 — There is a very detailed explanation of each of those in the manual.
[list]
  • [*][URL=http://es2.php.net/sprintf]sprintf()[/URL]
  • [*][URL=http://es2.php.net/printf]printf()[/URL]
  • [*][URL=http://es2.php.net/echo]echo()[/URL]
  • [*][URL=http://es2.php.net/print]print()[/URL]

  • [/list]
    ×

    Success!

    Help @nightster spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.7,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...