Jump to content

Recommended Posts

Hi, I  am trying to make a function that generates a function.

 

in otherwords want to make a function that can make a function.

 

for example:

 

function makefunction($name,$args,$code){

$assemble = function $name ($args) {$code} ;

return $assemble;
}

makefunction("tim","$money","if($money > 100){echo\" your really a rich man \";}");

echo tim(500);

 

The example should print out to screen the man is rich. I basically want to assemble the function and then later on use that function.

 

 

Is this possible? If so how would this be done?

 

I basically want to make a function that generates a function that can be stored in a file.

 

 

 

I seen that in the manual but don't know exaclty if that is what I am looking at.

 

 

I want to basically create a function on the fly and then store that new function in a file.

 

For example... lets say I want to make a menu where you can name the function and then select the arguments and  use a GUI interface to create the function or the logic that function should be doing.

 

then my script will grab those inputs read it and make sure nothing is harmful got written.

 

Then store the code in a file.

 

Would that function you told me about do the trick?

 

can you give me an example of how to use it?

Then just write the function to the file.

file_put_contents('file.php', '<? blah() { echo "hello world" } ?>');

 

Well, In the file it might have other code.

 

Plus would that function work... but I need to know how I can create the function. I don't want to manually write it.

 

I want my own script to generate the new function.

 

so the function be like 

$blah = monkey
function $blah ($money) { if ($monay > 100) {  echo " Your rich!!!  ";} 


the above would be   something like this:

function monkey ($money) { if ($monay > 100) {  echo " Your rich!!!  ";} 

 

that way in the file or page I can then put  monkey(800);

 

Which would spit out that I am rich on the screen.

 

Because 800  is greater then 100.

 

 

I need the function to be generated. I know how to make my own functions.

 

I just don't know how you can make a script generate or assemble it's own functions.

 

or create new functions each time those functions are runed.

 

I would love to hear the actual problem you're trying to solve. The one that you think this generating-functions-at-runtime stuff is the solution to.

Because honestly: this is all silly. There are much better ways.

I would love to hear the actual problem you're trying to solve. The one that you think this generating-functions-at-runtime stuff is the solution to.

Because honestly: this is all silly. There are much better ways.

 

 

I am trying to make a layout editor for my clients.. I am starting my own web hosting company. I want to allow my clients to be able to go to my website and login. Then they will have access to their account area.

 

The account area will have a layout and settings section. when you click layout editor you will go to a new page that shows at the top a drop down menu of all files created so far.

 

He can create a new page, or delete a page or modify a page. He can modfiy the layout and even program it.

 

For example, he can create his own databases and fill it with data. He can then grab that data and throw it out on his pages.

 

The thing is that I want a programming interface but don't feel comfortable to allow them to directly touch code.I don't want to have to deal with possible hackers to hack my website/ server.

 

So, I want to allow them to still program their website but they shouldn't have to know how to program to do this. It be easier for none technical people but at the same time will prevent the highly technical people to be able to do any damage to my server.

 

So, I need a way to generate web pages with my own code that will  generate php code and put it in these files and also generate javascript code and html and css for each file.

 

Think of it like dreamweaver it's a software that assists you to making a website. Yet, I want to make something like that but not allow you to actually touch code just click buttons or graphics to get the desired results or like right click on elements created on the page.

 

 

So, my problem is how can I make a script that will allow my clients to edit their website just as how a programmer can edit their website without having them touch a single line of code.

Take a look at closures.

 

Is there a way where I can create a function that has a name?  the reason is that I want to make a interface via javascript.

 

that when they right click on a element a menu fades in and in it one will be called processes.  Which when clicked I want to have a drop down menu that shows all functions the person created.

 

So it would show the name of the function. That way when it's selected they can also set the inputs to the function.

 

I basically need to have my code create the code. This is where I am getting at. Problem right now don't know how I can generate or create with my own php code a function.

 

Sounds more like you need to develop a CMS> Seriously, you are thinking about this backwards.

 

You shouldn't need to dynamically generate code, you need to dynamically generate content. There is a massive difference.

 

what do you mean by dynamically generate content?

 

What I want is to allow my clients to be able to design their website from ground up without touching any code.

 

I am not talking about using templates or something that is preset beforehand.

 

It needs to have the same effect like how programmers are able to create their website from ground up.

 

I want my clients to have th same freedom. Yet, not need to know how to program websites or anything.

 

It needs to have the same effect like how programmers are able to create their website from ground up.

 

I want my clients to have th same freedom. Yet, not need to know how to program websites or anything.

 

Sorry, but there is no such thing as programming without knowing how to program or not touching any code.

What you really want to do is create a WYSIWYG site editor/builder.  Here's the thing, though - they have limits, too, because it's impossible to take into account every possible thing a user would want to do on their site.  They tend to be 'dumb' out of necessity.

 

They'll never be able to make something as good as what a professional does if they can't/don't want to touch code. 

no, I am creating the interface to my site so they don't need to touch code.

 

I think it's possible. I have seen computer software programs. That you can buy for like $200.

 

you buy it and via buttons  clicking you make a make a website. Like the software generates the code and files into a folder.

 

Then you just ftp that folder to your server and walla a fully functional website in php and javascript that you didn't touch a single line of code at all.

 

I seen these programs. I so far never seen a website do the same function.

 

I know it's possible because it if weren't then how can hackers inject sql code or make some cross side scripts that will run on your website.

 

I mean what's the difference if a human wrote it or a computer script wrote the code?

 

 

I mean we all know the structure of a function

 

function  function_name (arguments) { code insert here } 

 

that's a function. if we know this then why can't we build one dynamically?

 

 

no, I am creating the interface to my site so they don't need to touch code.

 

I think it's possible. I have seen computer software programs. That you can buy for like $200.

 

you buy it and via buttons  clicking you make a make a website. Like the software generates the code and files into a folder.

 

Then you just ftp that folder to your server and walla a fully functional website in php and javascript that you didn't touch a single line of code at all.

 

I seen these programs.

 

Yes.  Like I said above, they're WYSIWYG - What You See Is What You Get.

 

I so far never seen a website do the same function.

 

Back in the day, Geocities had one.  It sucked.

 

I know it's possible because it if weren't then how can hackers inject sql code or make some cross side scripts that will run on your website.

 

What?  Hackers write scripts that point to another domain.  It's not hard.  And no, they don't point-and-click their way to success.

 

I mean what's the difference if a human wrote it or a computer script wrote the code?

 

 

I mean we all know the structure of a function

 

function  function_name (arguments) { code insert here } 

 

that's a function. if we know this then why can't we build one dynamically?

 

 

 

Someone must still code that first program that generates the dynamic code.  Nothing simply springs into existence fully formed.

 

But, really, the problem here is that you don't understand how computers, software, or the web actually work.  No WYSIWYG program can account for all possible actions a website may have to execute.  Even industry leading solutions like Dreamweaver simply contain a list of snippets that address common problems.  Anything more involved always requires getting your hands dirty and writing code.  Especially if it's something more complicated than, say, a blog.

 

Try getting your hands on a good WYSIWYG program, or search for a web-based one.  Take note of their similarities and shortfalls.

A WYSIWYG editor is exactly what you're looking for (or trying to make... but let's stick to looking for, at least for now.)

 

As defined by Wikipedia:

WYSIWYG implies a user interface that allows the user to view something very similar to the end result while the document is being created. In general WYSIWYG implies the ability to directly manipulate the layout of a document without having to type or remember names of layout commands.

 

And according to a decent (an older one, yes, but still good) Smashing Magazine article:

The somehow cryptic abbreviation WYSIWYG stands for “What You See Is What You Get”. In such editors you edit not directly the source code of your documents, but its presentation as it (hopefully) will appear in the final document. So instead of writing blocks of code manually (as you e.g. would do it in Word or Latex), you manipulate with design components using an editor window. This means that you view something very similar to the end result while the document or image is being created.

 

I so far never seen a website do the same function.

 

Back in the day, Geocities had one.  It sucked.

 

So did Homestead, and a whole bunch of others. They've mostly all died because Dreamweaver pretty much dominated the WYSIWYG market.

No, I  am not looking for a WYSIWYG.  With that you still have to write code.

 

I just created a script and got it  to work. I now have a working script that will generated the programming code via by you using my GUI on my website.

 

So, don't need the help anymore. Took me 4 days to figure out how I can write it without getting any errors.

  • 2 weeks later...

No, I  am not looking for a WYSIWYG.  With that you still have to write code.

 

I just created a script and got it  to work. I now have a working script that will generated the programming code via by you using my GUI on my website.

So, don't need the help anymore. Took me 4 days to figure out how I can write it without getting any errors.

 

yes, a WYSIWYG editor

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.