Helpful Information
 
 
Category: Post a PHP snippet
Filename & File extension from Path

This script is for use in isolating the extension and filename from a path or URL.


<?php
// Velox Letum (2005)
// [email protected]

$file = "include/435/file2.11032424.php"; // File path

echo substr($file, strrpos($file, "/") + 1) . "<br />"; // Filename, output: file2.11032424.php
echo substr($file, strrpos($file, ".") + 1); // File extension, output: php
?>

This script is for use in isolating the extension and filename from a path or URL.


<?php
// Velox Letum (2005)
// [email protected]

$file = "include/435/file2.11032424.php"; // File path

echo substr($file, strrpos($file, "/") + 1) . "<br />"; // Filename, output: file2.11032424.php
echo substr($file, strrpos($file, ".") + 1); // File extension, output: php
?>

Been using this, though in another form. Thought I would post it here.

It gets annoying to write out the substr() function everywhere so I made this just to make things simpler. It also allows me to use it alot more flexible.

pFV() - path File View

<?php

function pFV ($url, $method) {
// Velox Letum (2005) Modifications by Element
// [email protected] | [email protected]

if(isset($url) && isset($method)) {
if ($method == 0) {
$view = substr($file, strrpos($file, "/") + 1);
} elseif($method == 1) {
$view = substr($file, strrpos($file, ".") + 1);
} else {
$view = "pFV has encounted an error evaluating your settings.";
}
} else {
$view = "The URL or method was left blank.";
}

return $view;

}

$file = "include/435/file2.11032424.php"; // File path

echo pFV($file, 0)."<br />"; // Example filename, output: file2.11032424.php
echo pFV($file, 1); // Example file extension, output: php

if(strtolower(pFV($file 1)) == "php") { // Way of checking extension.
include $file;
}

?>

<?php
$file = 'include/435/file2.11032424.php';
$parts = pathinfo($file);
print_r($parts);

/* Array
(
[dirname] => include/435
[basename] => file2.11032424.php
[extension] => php
) */
?>


:cool:

Yes, that works, but that returns values that may not be used with the other method. pFV() and the regular substr() are aimed at the file. This function and method is obviously for the file, not the path.

Yes, that works, but that returns values that may not be used with the other method. pFV() and the regular substr() are aimed at the file. This function and method is obviously for the file, not the path.
What do you mean? pathinfo() is usually the best option for this. You can also specify a single bit of information to return... Take a look at http://www.php.net/pathinfo.

What do you mean? pathinfo() is usually the best option for this. You can also specify a single bit of information to return... Take a look at http://www.php.net/pathinfo.

I just mean that this function is entitled specifically for the file of the path. Sure pathinfo() can do it, but if you thought about it that way there are alot of duplicated functions that can do the same things that others can. Though these duplicates also have they're own purpose. Just like now pFV() is specifically for the file, ignoring anything before the last forward slash. And where as if I used pathinfo() I would be writing more whenever I want to use it. Now why would I want to do that? Pshaw. Lol.

Sorry if I'm weird but in our school are teacher thought it was cheating to rely on PHP functions when you can create them specifically for your scripts needs. It makes it alot more custom and shows more of the users creativety.

Okay, well its 8:43 AM, time for a couple more posts and maybe going back to bed before college. >.<

Sorry if I'm weird but in our school are teacher thought it was cheating to rely on PHP functions when you can create them specifically for your scripts needs. It makes it alot more custom and shows more of the users creativety.

I think you should possibly start ignoring your teacher. Seriously, PHP functions are there for just that reason.. to be used. Most are highly optimized in the core PHP interpreter. I'm quite surprised your teacher would tell you to replicate core PHP functions. It is by no means cheating to use the functionality PHP provides.

Also, my point is there is nothing special about your function that separates it from pathinfo, except that it doesn't do quite as much and is going to be slower than the built in function.

I think you should possibly start ignoring your teacher. Seriously, PHP functions are there for just that reason.. to be used. Most are highly optimized in the core PHP interpreter. I'm quite surprised your teacher would tell you to replicate core PHP functions. It is by no means cheating to use the functionality PHP provides.

Also, my point is there is nothing special about your function that separates it from pathinfo, except that it doesn't do quite as much and is going to be slower than the built in function.

Actually, its faster then pathinfo(), pathinfo() executes in 2.1 seconds on a blank page and pFV() executes in 1.7 seconds.

As far as my teacher, we use plenty of PHP functions, we just choose to take a piece of the cake, rather then the whole thing. Once again just because the function does the same thing doesn't mean its ideal for some situations. Just like with MySQL there are alot of methods of outputting MySQL results, some come out the same though may be longer then another. In a nut shell, there is no reason to argue or even mention pathinfo() because a duplicated function or something that does the same thing isn't going to end your world.

Everyone no matter what you think say or do will choose to code how they like. And considering I like my teacher and he is a program specialist I like his teachings. Honestly would you spend the time to make functions that do just what you want them to do? Obviously not. Well he does, and he gets paid up the *** for it.

If the college lab wasn't under intranet I could show you the entire Student CMS manager, it has a little file that lets you view the PHP sources of the pages.

Basically in conclusion. If you didn't like playing with functions and such, like we do in class (And we don't make functions like this one) then there would be no reason to upgrade PHP becuase it is people that make functions that open up new functions to add to PHP.

I think you dont fully understand how to use the pathinfo function, I wrote a test script to test its speed with random filenames. I used a loop of 10,000 for each:



Time taken on pFV method: 0.417667 seconds.
Time taken on pathinfo method: 0.295091 seconds.


Was my average outcome.

Here is the script I used to generate the results:


<?php

function pFV ($url, $method) {
// Velox Letum (2005) Modifications by Element
// [email protected] | [email protected]

if(isset($url) && isset($method)) {
if ($method == 0) {
$view = substr($url, strrpos($url, "/") + 1);
} elseif($method == 1) {
$view = substr($url, strrpos($url, ".") + 1);
} else {
$view = "pFV has encounted an error evaluating your settings.";
}
} else {
$view = "The URL or method was left blank.";
}

return $view;

}

$pFV_start = microtime(1);
for( $i = 0; $i < 10000; $i++ ){

$randomname = explode( "|", chunk_split( md5( uniqid() ), 8, "|" ) );
$randomname = "{$randomname[0]}/{$randomname[1]}/{$randomname[2]}.{$randomname[3]}";

$filename = pFV( $randomname, 0 );
$extension = pFV( $randomname, 1 );

}
$pFV_total = ( microtime(1) - $pFV_start );
echo 'Time taken on pFV method: <strong>' . round( $pFV_total, 6 ) . '</strong> seconds.';

$pit_start = microtime(1);
for( $i = 0; $i < 10000; $i++ ){

$randomname = explode( "|", chunk_split( md5( uniqid() ), 8, "|" ) );
$randomname = "{$randomname[0]}/{$randomname[1]}/{$randomname[2]}.{$randomname[3]}";

$filename = pathinfo( $randomname, PATHINFO_BASENAME );
$extension = pathinfo( $randomname, PATHINFO_EXTENSION );

}
$pit_total = ( microtime(1) - $pit_start );
echo '<br />Time taken on pathinfo method: <strong>' . round( $pit_total, 6 ) . '</strong> seconds.';

?>

My point is, the Pathinfo function is capable of doing more, and is faster than a custom coded equivilent, and is built into PHP and therefore uses less code.

I think you dont fully understand how to use the pathinfo function, I wrote a test script to test its speed with random filenames. I used a loop of 10,000 for each:



Time taken on pFV method: 0.417667 seconds.
Time taken on pathinfo method: 0.295091 seconds.


Was my average outcome.

Here is the script I used to generate the results:


<?php

function pFV ($url, $method) {
// Velox Letum (2005) Modifications by Element
// [email protected] | [email protected]

if(isset($url) && isset($method)) {
if ($method == 0) {
$view = substr($url, strrpos($url, "/") + 1);
} elseif($method == 1) {
$view = substr($url, strrpos($url, ".") + 1);
} else {
$view = "pFV has encounted an error evaluating your settings.";
}
} else {
$view = "The URL or method was left blank.";
}

return $view;

}

$pFV_start = microtime(1);
for( $i = 0; $i < 10000; $i++ ){

$randomname = explode( "|", chunk_split( md5( uniqid() ), 8, "|" ) );
$randomname = "{$randomname[0]}/{$randomname[1]}/{$randomname[2]}.{$randomname[3]}";

$filename = pFV( $randomname, 0 );
$extension = pFV( $randomname, 1 );

}
$pFV_total = ( microtime(1) - $pFV_start );
echo 'Time taken on pFV method: <strong>' . round( $pFV_total, 6 ) . '</strong> seconds.';

$pit_start = microtime(1);
for( $i = 0; $i < 10000; $i++ ){

$randomname = explode( "|", chunk_split( md5( uniqid() ), 8, "|" ) );
$randomname = "{$randomname[0]}/{$randomname[1]}/{$randomname[2]}.{$randomname[3]}";

$filename = pathinfo( $randomname, PATHINFO_BASENAME );
$extension = pathinfo( $randomname, PATHINFO_EXTENSION );

}
$pit_total = ( microtime(1) - $pit_start );
echo '<br />Time taken on pathinfo method: <strong>' . round( $pit_total, 6 ) . '</strong> seconds.';

?>

My point is, the Pathinfo function is capable of doing more, and is faster than a custom coded equivilent, and is built into PHP and therefore uses less code.

I don't understand, I used that same code and I get random results, sometimes pathinfo() is faster, and sometime pFV(). Though I'm on dialup as well. I'll try it on my computer.

My results come from 100 repeated tests.. I dont see any difference (except lack of features) between your function and the built in function, although you say there is.


Basically in conclusion. If you didn't like playing with functions and such, like we do in class (And we don't make functions like this one) then there would be no reason to upgrade PHP becuase it is people that make functions that open up new functions to add to PHP.

I agree with you fully, but why replicate built in functions, and make them slower at the same time... I dont doubt that your teacher is a qualified professional. My maths teacher was qualified professional, but she was a terrible teacher, and many of her methods didnt make sense.

The only time functions like that are good is for learning about how to use other functions (like substr() and strrpos()). In fact... why did you even use the substr function? Shouldnt you have used a for loop and accessed each variable character with $var{character} ?


Everyone no matter what you think say or do will choose to code how they like.

Again, I agree... Everyone has their own little quirks of programming, preferred methods, and adaptations on design patterns. That doesn't mean there isn't a bad and good way to do it.

Say you need to select 10 rows from a database of 10,000 rows... Do you limit the query to only select 10, or do you select all 10,000 and then get PHP to filter out just 10. Obviously, the good way to do it is to limit the query, but I have seen it done the other way. Regardless of personal preference, selecting all 10,000 rows when you only need ten is the bad way to do it.

I'm thankfull that I learned PHP by myself.

I just might add that PHP also has basename(), dirname() functions and the __FILE__ magic constant.

You can also let your scripts be nice and realtive and let the realpath() function add the full path.

On a final note: It is always better to use PHP functions as they will be updated (optimized/whatever) without you having to do anything.

Oh yeah, see only reason I used the substr() method was because the script a used for it. (An upload script) My friend asked how I could get the extension with substr() instead of pathinfo() or exploding it. So, I used this and also gave him the function because he kept writing the substrs wrong even though they're on the page to look at.

Honestly he doesn't know what he is doing with most of my friend, so I have often found myself moping(sp) about easy ways.

For example. I had a class that I edited and modified to make signatures based off of all the backgrounds i've made and gif images (Which are people, like Britney Spears, Korn, etc.) Well when I gave it to a friend I spent a week trying to get it too work for them. By the time I was done I had just realized I could have made an easy 130 dollars. Thats why I stick with easy code most the time because I quite litterally give my code away to anyone that asks, I don't believe in selling scripts because I would never buy a script.

I paid for the invision lisense when 1.3 final came out and was very dissapointed at how horrible the syntax was. It made everything hard to edit because it was not human readable (Well it was but not like what your teachers teach you, to make the code noticable as you scan through the file looking for something).

The easy way is not always the best way.

I don't know what the IPB Developers have to offer in coding style but writing code in a hard to read but short way is the easy, but not the best way as you see (phpBB has very good coding guidelines).

The easy way is not always the best way.

I don't know what the IPB Developers have to offer in coding style but writing code in a hard to read but short way is the easy, but not the best way as you see (phpBB has very good coding guidelines).

It has nothing to do with style or guidelines, its just common sense which any book or teacher teaches you from day one, always use pseudo code to explain large more complex code so a use doesn't have to spend a minutes reading out the code to imagine what it will do.

And as for the style, I thinky ou mean syntax. Developing easy to read through code like:



if($var == true) {

if($var == true) {

if($var == true) {

} else {

}

} else {

}

} else {

}



Which obviously looks so much better then solid blocks of code like:



if($var == true) {
if($var == true) {
if($var == true) {
} else {
}
} else {
}
} else {
}


See when reading alot of code like that, imagine more code in it, like 100 lines in each, it gets frustrating looking for correct closing curly brackets where as with correctly formated syntax you can easily find the curly bracket because you know what position the opening one is at. Like, two spaces in, for example.

I think you're missing the point. It is to do with coding style/guidelines, if you have a project with multiple people working on it, having them each code under their own coding style will end up with the code being very messy.

A project needs to set coding guidelines/standards/whatever-you-want-to-call-it and then stick to them.

I think you're missing the point. It is to do with coding style/guidelines, if you have a project with multiple people working on it, having them each code under their own coding style will end up with the code being very messy.

A project needs to set coding guidelines/standards/whatever-you-want-to-call-it and then stick to them.

Err, I see, then yes, that is what I was trying to show. I never called it that, we just figured out how to code it and stick with that syntax, so yes, it is styling/guidelines.

Err, I see, then yes, that is what I was trying to show. I never called it that, we just figured out how to code it and stick with that syntax, so yes, it is styling/guidelines.
All 3 of these follow the same syntax, but not the same styling/guidelines.

<?php

// Example 1
if ($num == 0) { echo 'Bob'; }

// Example 2
if ($num == 0) {
echo 'Bob';
}

// Example 3
if ($num == 0)
{
echo 'Bob';
}

?>

Guidelines are there for a reason, but may be different depending on a project. One coding guideline is often "dont duplicate built in functions unneccesarily", which is how this whole discussion started out.

All 3 of these follow the same syntax, but not the same styling/guidelines.

<?php

// Example 1
if ($num == 0) { echo 'Bob'; }

// Example 2
if ($num == 0) {
echo 'Bob';
}

// Example 3
if ($num == 0)
{
echo 'Bob';
}

?>

Yeah. I don't know why you guys call it styles or guidelines, its just as easily, and more simply, the format of the syntax. :thumbsup:

Yeah. I don't know why you guys call it styles or guidelines, its just as easily, and more simply, the format of the syntax. :thumbsup:
No... its not.

Syntax is the rigid way in which a language must be typed. This is the same for spoken languages as well as computer languages, its a set of instructions. For example, a capital letter must follow a full stop.

The style or guideline is the additional way we represent the code to promote readability. For example, in some exam papers teachers ask for double line spacing, not becuase the english language syntax calls for it, but becuase it makes it easier for them to write their comments.

No... its not.

Syntax is the rigid way in which a language must be typed. This is the same for spoken languages as well as computer languages, its a set of instructions. For example, a capital letter must follow a full stop.

The style or guideline is the additional way we represent the code to promote readability. For example, in some exam papers teachers ask for double line spacing, not becuase the english language syntax calls for it, but becuase it makes it easier for them to write their comments.

Yeah thats exaclty what the format of syntax is. Syntax being the code and the format of the code is how it is represented.

Grrr, this is starting to get on my nerves a bit now...

Format is a word usually used to describe a specific set of instructions... A PNG file is in PNG file format. If it wasnt in this format, it wouldn't be a PNG. The PHP function number_format formats a number to a specific format set. It is not given a guideline when formatting the number, its given a strict format.

An additional tab and indent in a PHP script is nothing to do with the file format, and IMO, should not be described as file formatting. When its interpreted, the PHP library doesn't care about spaces, tabs, indents etc unless they are meaningful (eg: in a string).

The guideline of coding would be a reccomended use, to promote readability. Say for example, you state that all declared functions should be camel-case (eg: readFileData()) and all opening braces should be proceeded by a newline and indent.. A model piece of code:



function readFileData(){
// Do something...
}


So.. We have a perfectly sensible guideline... What happens if we break the guideline though, and dont do a newline? Well.. nothing, we just dont have such easy readability, but no functionality is lost.

However, if the file format called for a newline and indent after every brace, and we broke the format by not doing that, the file should technically be corrupt (as it doesn't follow the format) and therefore wouldn't work. But of course, it would, hence why tabbing and indenting and other things to promote readability have nothing to do with the syntax format...

Grrr, this is starting to get on my nerves a bit now...

Format is a word usually used to describe a specific set of instructions... A PNG file is in PNG file format. If it wasnt in this format, it wouldn't be a PNG. The PHP function number_format formats a number to a specific format set. It is not given a guideline when formatting the number, its given a strict format.

An additional tab and indent in a PHP script is nothing to do with the file format, and IMO, should not be described as file formatting. When its interpreted, the PHP library doesn't care about spaces, tabs, indents etc unless they are meaningful (eg: in a string).

The guideline of coding would be a reccomended use, to promote readability. Say for example, you state that all declared functions should be camel-case (eg: readFileData()) and all opening braces should be proceeded by a newline and indent.. A model piece of code:



function readFileData(){
// Do something...
}


So.. We have a perfectly sensible guideline... What happens if we break the guideline though, and dont do a newline? Well.. nothing, we just dont have such easy readability, but no functionality is lost.

However, if the file format called for a newline and indent after every brace, and we broke the format by not doing that, the file should technically be corrupt (as it doesn't follow the format) and therefore wouldn't work. But of course, it would, hence why tabbing and indenting and other things to promote readability have nothing to do with the syntax format...

Oh jesus, Missing-Score, get over yourself. The word Format has its own god damn meaning, and one of this is how things are formated and displayed. Like a list, how a list is formated, alphabeticle, etc. Just like in code, if I choose to format my code using spaces.

Before you go geek on me think about what the word really means out side of coding as I am talking to you and not explaining code, I'm using words to describe things, to describe how I code, the format or layout of how my code is written.

Oh jesus, Missing-Score, get over yourself. The word Format has its own god damn meaning, and one of this is how things are formated and displayed. Like a list, how a list is formated, alphabeticle, etc. Just like in code, if I choose to format my code using spaces.

Before you go geek on me think about what the word really means out side of coding as I am talking to you and not explaining code, I'm using words to describe things, to describe how I code, the format or layout of how my code is written.
Ugh, close this thread please :rolleyes:

Before you go geek on me think about what the word really means out side of coding as I am talking to you and not explaining code, I'm using words to describe things, to describe how I code, the format or layout of how my code is written.

The point is, we are talking about the word in a coding context, sure, if we were talking about something else then fair enough, but its down right wrong to think of tabs as part of file formatting in a case when it doesn't matter.

I dont see why I should "get over myself" when clearly you are in the wrong, and have been pretty much throughout the entire thread. I dont exactly enjoy having to try and make up for incorrect information posted, but I think its important that new users dont think that your posted function was the best way to get path information and that part of PHP's file formatting involves tabs and indents.

Anyways, I agree with ralph l mayo and will most likley be closing this thread sometime soon as it doesn't seem to be going anywhere.

The point is, we are talking about the word in a coding context, sure, if we were talking about something else then fair enough, but its down right wrong to think of tabs as part of file formatting in a case when it doesn't matter.

I dont see why I should "get over myself" when clearly you are in the wrong, and have been pretty much throughout the entire thread. I dont exactly enjoy having to try and make up for incorrect information posted, but I think its important that new users dont think that your posted function was the best way to get path information and that part of PHP's file formatting involves tabs and indents.

Anyways, I agree with ralph l mayo and will most likley be closing this thread sometime soon as it doesn't seem to be going anywhere.

How am I in the wrong? I am not in the wrong because I havn't done anything wrong. When you talk to someone you talk to them. Just because a computer language componant is named something, like a file format or type. But you need to know when thats what the words mean. If i'm obviously describing the style/guideline of a code I can use format as freely as I like because it is a word that describes it in the correct way.

Just as Error 404 said "guidelines/standards/whatever-you-want-to-call-it"

And there is no reason to close the thread because if you guys just now feel concerned with it even though its an old thread, and its apparently a useless method, why not just delete it? Apparently its not usefull and doesn't fall under the forum guidelines.

How am I in the wrong? I am not in the wrong because I havn't done anything wrong. When you talk to someone you talk to them. Just because a computer language componant is named something, like a file format or type. But you need to know when thats what the words mean. If i'm obviously describing the style/guideline of a code I can use format as freely as I like because it is a word that describes it in the correct way.

And there is no reason to close the thread because if you guys just now feel concerned with it even though its an old thread, and its apparently a useless method, why not just delete it? Apparently its not usefull and doesn't fall under the forum guidelines.

Yes, you are free to use the word format, but the context matters. You make it sound like your readability formatting is part of the PHP file format, which it is not, and therefore, you are wrong if you were implying that. If you werent, then thats fair enough, you are not incorrect, but I want it to be completley clear, becuase its little things like this that can potentially hold people back.

For example, up until 6 months ago, I didnt know you could do:


$object->function()->somethingElse()->SomethingElse;

Becuase I was told once that it was not possible, I never questioned it. I only questioned it when I saw it in a script, and found out it was possible and I had been misguided. Since then, I have done my best to ensure that misguiding information is not given out becuase it can potentially hold back someones progression. If someone comes here and gets the impression that formatting for readability is neccesary and is part of a PHP file format then they have been misguided, which is what I am trying to prevent.

I wouldn't delete the thread becuase i feel earlier on some useful points were discussed in terms of execution time and usage. While its true that your inital function is is a slower duplicate of a built in function, it is still useful, say for a beginner to see that the built in function is quicker and to learn about the built in function if they have never seen it before. I'm only continuing to argue my point becuase it would be nice if we could leave it open to any further discussion on the original post, however, it doesn't look like its going to happen.

Disclaimer, I am not a licensed morphologist or grammarian, but, imho:

Format and syntax both have special meanings in computer science. Format refers to schema for the arrangement of data, and syntax refers to a schema for the arrangment of logic. To say "format of the syntax" is kind of like saying "apple of the orange", although it's true most people will probably get your meaning.



$var = array('one', 'two', 'three');
$var[0] = 'one';
$var[1] = 'two';
$var[3] = 'three';
// same format (data), different syntax (logic)

$varone = 'one';
$vartwo = 'two';
$varthree = 'three';
$varone = 1;
$vartwo = 2;
$varthree = 3;
// same syntax (logic), different format (data)

if (true) { echo $var; }
if (true)
{
echo $var;
}
// same syntax, same format, different style

ugh... see thats why I hate typing out text. You always forget something and can never quite get clear without writing a couple paragraphs. Yes I know what you both mean, and I understand that, but what I mean has to do with the english language, which is why I used format as my descriptor.

Anyways, I'm not going to continue to reply to this topic, it has so much junk people will think are valid posts with usefull information partaining to the topic title. Though there is other usefull information which could almost be revised for a Computer Language FAQ (About the code its self).

I also happen to find style important...I use K&R braces, I use single quotes for anything that doesn't need to have double quootes, I enjoy well-formatted code which is why indents are built into my PHP, HTML, and HTML in PHP (such as echoes), but everyone has their style. Some use different brace types, some put spaces between a function's parenthesis and any passed variables. Nobody's style is the best, though in my opinion I'd have to say the one that promotes code-readability is the best.

This snippit of code I wrote before I even knew basename(), pathinfo(), and other such functions existed, and had I known I wouldn't have even posted this snippit, however I do find it important that programmers learn how to solve problems creatively and not just rely on functions served to them. I was working on a project that required me to parse paths and get the name of the file and extension, thus I wrote this code. I suppose it could be a lesson...there's always another way to something.

I see that I have succesfully started pretty big argument by using difficult words like "style" or "guideline"... :D

I just might add that you can "sense" the writers personality when you look at how he writes things. You can see if that person knows what and to whom he is writing to. Depending on the reciever the same meaning should be convaeyd in different ways. When I see someones code (though it can be normal writing aswell) I can see if the person is lazy or if he wrote it in a hurry (and some other thigns too). Make conclusions as you like.



For example, up until 6 months ago, I didnt know you could do:
$object->function()->somethingElse()->SomethingElse;
Becuase I was told once that it was not possible, I never questioned it. I only questioned it when I saw it in a script, and found out it was possible and I had been misguided. Since then, I have done my best to ensure that misguiding information is not given out becuase it can potentially hold back someones progression. If someone comes here and gets the impression that formatting for readability is neccesary and is part of a PHP file format then they have been misguided, which is what I am trying to prevent.

I might clean that someones record. Dircet access to a method of an object returned by a function is possible from PHP5 and up. In PHP4 you would have to assign the returned object to a variabale.

BTW reading what you wrote is a good idea.

When you talk to someone you talk to them.
I still wonder what that sentance means/does.

Just as Error 404 said "guidelines/standards/whatever-you-want-to-call-it"
As my last post was trying to point out, all 3 of the examples follow the same syntax (if, bracket, if statement, bracket, curved bracket, echo, curved bracket), yet they do not follow the same guidelines.

Syntax and guidelines are two very different things.

If you break the Syntax, the code will die horribly. If you break the guidelines, it'll work fine.

Okay, you guys are purposely starting up a conversation which has been over for a day now. And indeed, I know what syntax is, which is why I can use my descriptor on syntax all I want, you can't tell me otherwise. The way a format my syntax just means the way its styled. Though I never put 'guidelines' down since I'm often coding alone because my friends are the type that slack and won't even help me... even if they offer the help. :mad:

And despite what you all say anyone I talk to on messenger, they know exactly what I mean and even say syntax is the code, therefor what I say is perfectly fine. All you guys are doing is contradicting, this isn't even an argument. It has no valid or usefull point, and thus your simply telling me no to give me a bad time becaus you can't deal with the fact I can easily use "format my syntax/coding/programing/writing"

No, we're trying to point out syntax and coding styling are two very different things.


<?php

// Example 1
if ($num == 0) { echo 'Bob'; }

// Example 2
if ($num == 0) {
echo 'Bob';
}

// Example 3
if ($num == 0)
{
echo 'Bob';
}

?>

These all follow the same syntax.
These all follow different coding styles.

No, we're trying to point out syntax and coding styling are two very different things.


<?php

// Example 1
if ($num == 0) { echo 'Bob'; }

// Example 2
if ($num == 0) {
echo 'Bob';
}

// Example 3
if ($num == 0)
{
echo 'Bob';
}

?>

These all follow the same syntax.
These all follow different coding styles. Yes I understand that, but your not thinking of it correctly. Same syntax, different format. Thus, different formatting of the same syntax. I'm not saying when I format the syntax the syntax is changed, its just formatted differently just like you showed.

Yes I understand that, but your not thinking of it correctly. Same syntax, different format. Thus, different formatting of the same syntax. I'm not saying when I format the syntax the syntax is changed, its just formatted differently just like you showed.
I dont believe I am having to come back here again, but if you read ralph l mayo's post, he describes is best in my opinion, and Element, all those are the same format... Please, just give it a rest and accept that you are wrong when we are talking about the meaning of formatting in the usual context. If it makes sense to you then so be it, but please stop arguing your case.

I dont believe I am having to come back here again, but if you read ralph l mayo's post, he describes is best in my opinion, and Element, all those are the same format... Please, just give it a rest and accept that you are wrong when we are talking about the meaning of formatting in the usual context. If it makes sense to you then so be it, but please stop arguing your case.
Leave it up to the Europians to be as arrogant as they can. Usual contect? Serious, grab a dictionary, thats the usual context, period. Format the same? Pshaw, right.


2 format

determine the arrangement of (data) for storage and display (in computer science)


One of the many uses of the word format, even in computer science. I'm tired of you guys making it sound like I'm wrong when you have no grounds what-so-ever considering I'm using the word correctly as a descriptor for the storage and display of my code.

If you need to read up on other uses of the word format check out: http://www.wordreference.com/definition/format

"I format my code so it will fit my coding style."
"I have to change my coding style to fulfill the coding guidelines of my project."
How about that?

"I format my code so it will fit my coding style."
"I have to change my coding style to fulfill the coding guidelines of my project."
How about that?

Mmm its like chocolate covered strawberries.... :rolleyes:

the organization of information according to preset specifications (usually for computer processing)

Which was my whole argument with you in the first place... That tabs and indents have nothing to do with PHP file formatting... That was what I was intending to point out initially and I have already said I didnt want to spring a whole argument from it.

I'm going to ignore the whole europeans remark too.

the organization of information according to preset specifications (usually for computer processing)

Which was my whole argument with you in the first place... That tabs and indents have nothing to do with PHP file formatting... That was what I was intending to point out initially and I have already said I didnt want to spring a whole argument from it.

I'm going to ignore the whole europeans remark too.

Yes, but you see, thats for format once again. The argument was about me using format. Either way the basic meanings of format is the aspect and visual aspects of something. Either or are correct, it is a word that can be used in so many different ways.

Like the styling of the code is a title for how each individual formats their code.

Yes, but you see, thats for format once again. The argument was about me using format. Either way the basic meanings of format is the aspect and visual aspects of something. Either or are correct, it is a word that can be used in so many different ways.

Like the styling of the code is a title for how each individual formats their code.
Yes... I understand what you are saying, as I always have. I was trying to point out that a newline and indent have nothing to do withPHP FILE FORMAT. If you are talking obout the visual format in which PHP is seen, then you are right, which I never disputed.

Yes... I understand what you are saying, as I always have. I was trying to point out that a newline and indent have PHP FILE FORMAT. If you are talking obout the visual format in which PHP is seen, then you are right, which I never disputed.

*Gets blown into his closet* I know, it wasn't really you that did, but other people just excused what I was saying without even understanding it.










privacy (GDPR)