1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

problem with the use of sprint

Discussion in 'PHP' started by themaster, Jun 20, 2017.

  1. #1
    Is anyone can help me about why I am getting this error?
    PHP Warning: sprintf(): Too few arguments in but no sprintf in

    The related function is:
    function httpcheckif(){
      return sprintf(
        isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http',

    Solved! View solution.
    Last edited by a moderator: Jun 20, 2017
    themaster, Jun 20, 2017 IP
  2. #2
    You have one too many %s in the sprintf.
    The correct line should be:
    Code (markup):
    PoPSiCLe, Jun 20, 2017 IP
    themaster likes this.
  3. themaster

    themaster Well-Known Member

    Likes Received:
    Best Answers:
    Trophy Points:
    Thanks :)
    themaster, Jun 20, 2017 IP
  4. deathshadow

    deathshadow Acclaimed Member

    Likes Received:
    Best Answers:
    Trophy Points:
    printf is one of those commands I never really understood why they exist in the first place.... as if string addition is so magically hard or that it's somehow worth running a parser under a parser under an interpreter.

    Which is why I'd have scrapped that and simply done:
    function httpcheckif(){
    	return (
    		isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http'
    	) . '://' . $_SERVER['SERVER_NAME'];
    Code (markup):
    Even in C all "printf" type commands are is a legacy of the fact that the early compilers were all single-pass trash... that it even exists in modern languages like PHP is more a monument to stupidity than it is functionality.
    deathshadow, Jun 24, 2017 IP